
; Entry points
C30000:  JMP C3001B      ; Invoke desired field menu
         JMP C3AC70      ; Decode joypads for battle
         JMP C3AC4F      ; Initialize joypad data
         JMP C3ACA5      ; Decode joypads for field
         JMP C31433      ; Advance play time
         JMP C31569      ; Load save data on defeat
         JMP C3D48B      ; Show an ending cinematic
         JMP C39EC1      ; Optimize member's gear
         JMP C3E4E4      ; Load map for final land

; Invoke requested field menu
C3001B:  REP #$10        ; 16-bit X, Y
         SEP #$20        ; 8-bit A
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDX #$0000      ; Zero X
         PHX             ; Put on stack
         PLD             ; Set DP to 0
         LDX #$0000      ; ...
         STX $00         ; Optimzn word: 0
         LDA #$7E        ; Bank: 7E
         STA $2183       ; Set WRAM HB
         JSR C300C0      ; Reroute NMI/IRQ
         LDA $0200       ; Menu to open
         CMP #$02        ; Load menu?
         BNE C3003F      ; Branch if not
         JSR C3782F      ; Reset game data
C3003F:  JSR C300F8      ; Load GFX, colors
         JSR C300DD      ; Handle menu
         JSL C3AC4F      ; Get joypad config
         LDA #$8F        ; BRT: 15 and OFF
         STA $2100       ; Disable screen
         STZ $4200       ; Disable INT, pad
         STZ $420B       ; Disable DMA...
         STZ $420C       ; Disable HDMA

; Fork: Leaving Load menu
C30057:  LDA $0200       ; Menu closed
         CMP #$02        ; Load menu?
         BNE C3006F      ; Branch if not
         LDA $0205       ; Start new game?
         BPL C3006F      ; Branch if so
         LDA $1D4E       ; Game options
         AND #$20        ; Stereo sound?
         BEQ C3006F      ; Branch if so
         LDA #$FF        ; Mode: Mono
         JSR C33F46      ; Adjust volume

; Fork: Rename Card
C3006F:  LDA $0200       ; In main menu?
         BNE C300BF      ; Return if not
         LDA $0205       ; Rename request?
         BPL C300BF      ; Return if not
         CMP #$FE        ; Rename actor?
         BNE C3009E      ; SwdTech if not
         LDA #$01        ; Actor renaming
         STA $0200       ; Set menu number
         LDA $0201       ; Area permissions
         STA $020F       ; Preserve them
         LDY $0206       ; Actor's address
         STY $0201       ; Set as target's
         JSL C30000      ; Call naming menu
         LDA $020F       ; Area permissions
         STA $0201       ; Restore them
         STZ $0200       ; Menu: Main
         JMP C3001B      ; Open main menu

; Fork: SwdTech renaming
C3009E:  LDA #$06        ; SwdTech renaming
         STA $0200       ; Set menu number
         LDA $0201       ; Area permissions
         STA $020F       ; Preserve them
         LDA $0206       ; Chosen SwdTech
         STA $0201       ; Set as target
         JSL C30000      ; Call naming menu
         LDA $020F       ; Area permissions
         STA $0201       ; Restore them
         STZ $0200       ; Menu: Main
         JMP C3001B      ; Open main menu
C300BF:  RTL

; Reroute interrupt vectors
C300C0:  LDA #$5C        ; JML opcode
         STA $1500       ; Put by NMI loc
         STA $1504       ; Put by IRQ loc
         LDX #C313F2     ; C3/13F2
         STX $1501       ; Set NMI LBs
         LDX #C31432     ; C3/1432
         STX $1505       ; Set IRQ LBs
         LDA #$C3        ; Bank: C3
         STA $1503       ; Set NMI HB
         STA $1507       ; Set IRQ HB
         RTS

; Access requested field menu
C300DD:  TDC             ; Clear A
         LDA $0200       ; Menu to open
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C300E6,X)  ; Invoke menu

; Jump table for the above
C300E6:  dw C3011A       ; Main menu
         dw C301B3       ; Actor naming
         dw C3016F       ; Load menu
         dw C30121       ; Shop
         dw C3012B       ; Lineup
         dw C3013D       ; Bogus...
         dw C30149       ; SwdTech naming
         dw C30152       ; Colosseum
         dw C30166       ; Final battle lineup

; Load menu graphics and colors; initialize general variables
C300F8:  JSR C3706C      ; Reset variables
         JSR C37087      ; Get party info
         JSR C3711B      ; No use...
         JSL $D4CD48     ; Init registers
         JSL C3AC4F      ; Init joypad data
         TDC             ; Gradient set: 0
         JSL $D4CA1D     ; Create gradient
         JSR C37170      ; Queue Win1 HDMA
         JSR C3117F      ; Reset OAM, queue
         JSR C3721B      ; Load nonskin GFX
         JMP C33B5B      ; Load skin visuals

; Invoke main menu
C3011A:  LDA #$04        ; C3/1AF0
         STA $26         ; Next: Init menu
         JMP C301BA      ; Enter menu loop

; Invoke shop menu
C30121:  JSR C340B9      ; Apply user font
         LDA #$24        ; C3/C3C0
         STA $26         ; Next: Init menu
         JMP C301BA      ; Enter menu loop

; Invoke Lineup menu
C3012B:  JSR C340B9      ; Apply user font
         JSR C30138      ; Clear saved cursor
         LDA #$2C        ; C3/787B
         STA $26         ; Next: Init menu
         JMP C301BA      ; Enter menu loop

; Clear cursor position restored from Lineup's Status menu...
C30138:  TDC             ; Clear A
         TAY             ; Clear Y
         STY $8E         ; Clear position
         RTS

; Invoke bogus Lineup menu...
C3013D:  JSR C340B9      ; Apply user font
         JSR C30138      ; Clear saved cursor
         LDA #$2F        ; C3/826C
         STA $26         ; Next: Bogus...
         BRA C301BA      ; Enter menu loop

; Invoke SwdTech naming menu
C30149:  JSR C340B9      ; Apply user font
         LDA #$3F        ; C3/BE00
         STA $26         ; Next: Init menu		=== SNES: Bogus
         BRA C301BA      ; Enter menu loop

; Invoke Colosseum menu
C30152:  JSR C340B9      ; Apply user font
         STZ $79         ; Never read...
         STZ $7A         ; Never read...
         STZ $7B         ; Never read...
         LDA #$FF        ; Empty item
         STA $0205       ; Will gain 1...
         LDA #$71        ; C3/B619
         STA $26         ; Next: Init menu
         BRA C301BA      ; Enter menu loop

; Invoke final battle lineup
C30166:  JSR C340B9      ; Apply user font
         LDA #$73        ; C3/B368
         STA $26         ; Next: Init menu
         BRA C301BA      ; Enter menu loop

; Invoke Load menu
C3016F:  LDA $307FF1     ; RNG index in SRAM
         INC A           ; RNG index +1
         STA $307FF1     ; Save changes
         JSL C3AC4F      ; Init joypad data
         JSR C377B7      ; Test SRAM markers
         BCC C3019F      ; Abort if invalid
         LDA #$01        ; Song: The Prelude
         STA $1301       ; Set I/O port 1
         LDA #$10        ; APU command
         STA $1300       ; Set I/O port 0
         LDA #$80        ; Volume specs
         STA $1302       ; Set I/O port 2
         JSL $C50004     ; Play song
         LDA #$FF        ; New game: No
         STA $0205       ; Preset exit mode
         LDA #$20        ; C3/1D69
         STA $26         ; Next: Init menu
         BRA C301BA      ; Enter menu loop

; Fork: Force new game
C3019F:  JSR C32ABC      ; Reset play time
         LDA #$01        ; Save slot: 1
         STA $0224       ; Set last viewed
         STZ $021F       ; Game's file: None
         LDA #$FF        ; Null value
         STA $26         ; Next: Exit menu
         STZ $0205       ; Set new game mode
         BRA C301BA      ; Enter menu loop

; Invoke actor naming menu
C301B3:  JSR C340B9      ; Apply user font
         LDA #$5D        ; C3/6B5E
         STA $26         ; Next: Init menu

; Main loop for field menus
C301BA:  JSR C3147D      ; Refresh screen
C301BD:  TDC             ; Clear A
         LDA $26         ; Menu command
         CMP #$FF        ; Exit to map?
         BEQ C301D8      ; Branch if so
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         JSR (C301DB,X)  ; Handle menu cmd
         JSR C3121B      ; Handle anim queue
         JSR C313B8      ; Update screen/pad
         JSR C302DB      ; Check event timer
         BRA C301BD      ; Loop
C301D8:  STZ $43         ; Disable HDMA
         RTS

; Jump table for the above
C301DB:  dw C31DD7       ; 00: Fade out screen
         dw C31DE4       ; 01: Fade in screen
         dw C31DF1       ; 02: Wait while menu fades in or out
         dw C31DFA       ; 03: Exit main menu's portrait area
         dw C31AF0       ; 04: Initialize main menu
         dw C31E0A       ; 05: Sustain main menu
         dw C31E4E       ; 06: Target one actor in main menu
         dw C31B3C       ; 07: Initialize Item menu
         dw C31F5D       ; 08: Handle Item menu choice 1
         dw C31BC1       ; 09: Initialize Skills menu
         dw C3205A       ; 0A: Sustain Skills menu
         dw C31CAC       ; 0B: Initialize Status menu
         dw C32255       ; 0C: Sustain Status menu
         dw C31CE3       ; 0D: Initialize Config menu
         dw C32325       ; 0E: Sustain Config menu
         dw C3247F       ; 0F: Handle Order menu choice 1
         dw C324C6       ; 10: Handle Order menu choice 2
         dw C3251C       ; 11: Switch members in Order menu
         dw C325AA       ; 12: Wait while member changes row
         dw C31D06       ; 13: Initialize Save menu
         dw C325B3       ; 14: Sustain Save menu
         dw C31D49       ; 15: Initialize save confirmation
         dw C32610       ; 16: Sustain save confirmation
         dw C32667       ; 17: Handle Item menu options
         dw C327B4       ; 18: Sustain rare item menu
         dw C327EC       ; 19: Handle Item menu choice 2
         dw C32855       ; 1A: Sustain Magic menu
         dw C328FD       ; 1B: Sustain Lore menu
         dw C3291D       ; 1C: Sustain Dance menu
         dw C3292D       ; 1D: Sustain Rage menu
         dw C32946       ; 1E: Handle esper selection
         dw C32610       ; 1F: Unused duplicate...
         dw C31D69       ; 20: Initialize Load menu
         dw C32A5D       ; 21: Sustain Load menu
         dw C31DB7       ; 22: Initialize load confirmation
         dw C32AC5       ; 23: Sustain load confirmation
         dw C3C3C0       ; 24: Initialize shop menu
         dw C3C3F2       ; 25: Sustain main shop menu
         dw C3C414       ; 26: Handle buy item list
         dw C3C45C       ; 27: Handle buy order menu
         dw C3C565       ; 28: Return to Buy menu after delay
         dw C3C56D       ; 29: Handle sell item list
         dw C3C5CD       ; 2A: Handle sell order menu
         dw C3C6A9       ; 2B: Return to Sell menu after delay
         dw C3787B       ; 2C: Initialize Lineup menu
         dw C378FC       ; 2D: Handle Lineup menu choice 1
         dw C379A0       ; 2E: Handle Lineup menu choice 2
         dw C3826C       ; 2F: Bogus...
         dw C382AC       ; 30: Bogus...
         dw C382AC       ; 31: Bogus...
         dw C382AC       ; 32: Bogus...
         dw C329E1       ; 33: Sustain Blitz menu
         dw C329AD       ; 34: Wait while showing who holds esper
         dw C31C1E       ; 35: Initialize Equip menu
         dw C39E10       ; 36: Handle Equip menu options
         dw C31F1B       ; 37: Handle multitargeting in main menu
         dw C31C98       ; 38: Initialize party gear overview
         dw C329D0       ; 39: Sustain party gear overview
         dw C32B00       ; 3A: Initialize spell usage menu
         dw C32B49       ; 3B: Handle single-target spell
         dw C32DB7       ; 3C: Return to Magic menu
         dw C32E13       ; 3D: Handle multitarget spell
         dw C329F8       ; 3E: Sustain SwdTech menu
         dw C3BE00       ; 3F: Initialize SwdTech naming menu
         dw C3BE37       ; 40: Handle SwdTech naming choice 1
         dw C3BE7A       ; 41: Handle SwdTech naming choice 2
         dw C36966       ; 42: Initialize Lineup's Status menu
         dw C36988       ; 43: Sustain Lineup's Status menu
         dw C384A3       ; 44: Bogus...
         dw C384A3       ; 45: Bogus...
         dw C384A3       ; 46: Bogus...
         dw C343A3       ; 47: Initialize Cmd.Set menu
         dw C343C0       ; 48: Handle Cmd.Set menu member selection
         dw C3478E       ; 49: Initialize Button Settings menu
         dw C347AB       ; 4A: Sustain Button Settings menu
         dw C347E2       ; 4B: Initialize Controller menu
         dw C347FF       ; 4C: Sustain Controller menu
         dw C35F23       ; 4D: Sustain esper data menu
         dw C3BEEF       ; 4E: Scroll to SwdTech naming page 2
         dw C3BF17       ; 4F: Scroll to SwdTech naming page 1
         dw C33AD4       ; 50: Scroll to Config page 2
         dw C33AF5       ; 51: Scroll to Config page 1
         dw C31A73       ; 52: Queue fade-in for save menu
         dw C31A64       ; 53: Queue fade-out for save menu
         dw C31A82       ; 54: Wait while save menu fades in or out
         dw C3A073       ; 55: Handle selection of gear slot to fill
         dw C3A0BE       ; 56: Handle manual gear removal
         dw C3A0FE       ; 57: Handle gear browsing
         dw C3A659       ; 58: Initialize Relic menu
         dw C3A6C6       ; 59: Handle Relic menu options
         dw C3A80B       ; 5A: Handle selection of relic slot to fill
         dw C3A8A5       ; 5B: Handle relic browsing
         dw C3A918       ; 5C: Handle relic removal
         dw C36B5E       ; 5D: Initialize actor naming menu
         dw C39170       ; 5E: Sustain shifted gear data menu
         dw C36BA5       ; 5F: Sustain actor naming menu
         dw C36C4A       ; 60: Scroll to actor naming page 2
         dw C36C71       ; 61: Scroll to actor naming page 1
         dw C34419       ; 62: Handle Cmd.Set menu command choice 1
         dw C34457       ; 63: Handle Cmd.Set menu command choice 2
         dw C3910D       ; 64: Sustain non-shifted gear data menu
         dw C337AF       ; 65: Shift screen
         dw C38193       ; 66: Queue fade-in for Lineup menu
         dw C38184       ; 67: Queue fade-out for Lineup menu
         dw C381A2       ; 68: Wait while Lineup menu fades in or out
         dw C3821B       ; 69: Erase warning in Lineup menu after delay
         dw C369F0       ; 6A: Sustain shifted Status menu
         dw C32314       ; 6B: Unknown, unused menu mode...
         dw C3A7BF       ; 6C: Handle delayed fade-out for Reequip
         dw C31C80       ; 6D: Open Equip menu after optimizing gear
         dw C31C8C       ; 6E: Open Equip menu after removing all gear
         dw C3920E       ; 6F: Initialize item usage menu
         dw C39220       ; 70: Sustain item usage menu
         dw C3B619       ; 71: Initialize Colosseum item menu
         dw C3B64B       ; 72: Sustain Colosseum item menu
         dw C3B368       ; 73: Initialize final battle lineup
         dw C3B395       ; 74: Sustain final battle lineup
         dw C3B724       ; 75: Initialize Colosseum matchup menu
         dw C3B77C       ; 76: Sustain Colosseum matchup menu
         dw C31B9B       ; 77: Return from item usage menu
         dw C3B6F9       ; 78: Bogus...
         dw C3A68B       ; 79: Swap actor in Relic menu, retain Equip mode
         dw C3A699       ; 7A: Swap actor in Relic menu, retain Remove mode
         dw C30000       ; 7B: Bogus...
         dw C30000       ; 7C: Bogus...
         dw C378C5       ; 7D: Return to Lineup menu from Status menu
         dw C31C4B       ; 7E: Swap actor in Equip menu, retain Equip mode
         dw C31C59       ; 7F: Swap actor in Equip menu, retain Remove mode

; Set to exit menu if event countdown timer expired
C302DB:  LDA $B4         ; Already handled?
         BNE C302F8      ; Exit if so
         LDA $1188       ; Timer 0 flags
         BIT #$20        ; Abort if expired?
         BEQ C302F8      ; Exit if not
         LDY $1189       ; Timer expired?
         BNE C302F8      ; Exit if not
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         LDA #$05        ; Origin: Timer
         STA $0205       ; Set exit reason
         STA $B4         ; Disable this fn
C302F8:  RTS

; Draw text string without diacritics			=== SNES: Single text function, not two
C302F9:  STY $E7         ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
C302FF:  LDX $00         ; Dst index: 0
         TXY             ; Src index: 0
         REP #$20        ; 16-bit A
         LDA [$E7]       ; Tilemap ptr
         STA $EB         ; Set dst LBs
         INC $E7         ; Src adr +1
         INC $E7         ; Src adr +1
         SEP #$20        ; 8-bit A
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
C30312:  LDA [$E7],Y     ; Text character
         BEQ C30325      ; Exit if <end>
         PHY             ; Save src index
         TXY             ; Dst index
         STA [$EB],Y     ; Add char to map
         INX             ; Dst index +1
         TXY             ; Move it to Y
         LDA $29         ; Palette, etc.
         STA [$EB],Y     ; Set attributes
         INX             ; Dst index +1
         PLY             ; Src index
         INY             ; Src index +1
         BRA C30312      ; Load next char
C30325:  RTS

; Draw text string with diacritics but without Roman characters		%%%
C30326:  STY $E7         ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
C3032C:  LDX $00         ; Dst index: 0
         TXY             ; Src index: 0
         REP #$20        ; 16-bit A
         LDA [$E7]       ; Tilemap ptr
         STA $EB         ; Set dst LBs
         INC $E7         ; Src adr +1
         INC $E7         ; Src adr +1
         SEP #$20        ; 8-bit A
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB

; Fork: Load current character
C3033F:  LDA [$E7],Y     ; Text character
         STA $E0         ; Memorize it
         BEQ C303A8      ; Exit if <end>

; Fork: Handle line break (unused?)
C30345:  CMP #$01        ; Line break?
         BNE C3035A      ; Branch if not
         REP #$20        ; 16-bit A
         LDA $EB         ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$0080      ; Go 2 rows down
         STA $EB         ; Save changes
         LDX $00         ; Dst index: 0
         SEP #$20        ; 8-bit A
         INY             ; Src index +1
         BRA C3033F      ; Load next char

; Fork: Character without diacritic
C3035A:  PHY             ; Save src index
         CMP #$53        ; Normal char?
         BCC C30365      ; Branch if not
         LDA #$FF        ; Space char
         STA $E1         ; Set diacritic
         BRA C30385      ; Update tilemap

; Fork: Character with handakuten
C30365:  CMP #$49        ; Bogus char?
         BCC C30376      ; Branch if not
         LDA #$52        ; Mark: [°]
         STA $E1         ; Set diacritic
         LDA $E0         ; Letter number
         CLC             ; Prepare ADC
         ADC #$17        ; Get true one
         STA $E0         ; Save changes
         BRA C30385      ; Update tilemap

; Fork: Character with dakuten
C30376:  CMP #$20        ; Roman range?
         BCC C30385      ; Branch if not
         LDA #$51        ; Mark: ["]
         STA $E1         ; Set diacritic
         LDA $E0         ; Letter number
         CLC             ; Prepare ADC
         ADC #$40        ; Get true one
         STA $E0         ; Save changes

; Fork: Add character to tilemap
C30385:  TXY             ; Base dst index
         LDA $E1         ; Diacritic
         STA [$EB],Y     ; Add to tilemap
         INY             ; Index +1
         LDA $29         ; Palette, etc.
         STA [$EB],Y     ; Set attributes
         REP #$20        ; 16-bit A
         TXA             ; Base RAM index
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         LDA $E0         ; Base character
         STA [$EB],Y     ; Add to tilemap
         INY             ; Index +1
         LDA $29         ; Palette, etc.
         STA [$EB],Y     ; Set attributes
         INX             ; Dst index +1
         INX             ; Dst index +1
         PLY             ; Src index
         INY             ; Src index +1
         BRA C3033F      ; Load next char
C303A8:  RTS

; Load and adjust window tile numbers, define attributes
C303A9:  STY $E7         ; Save attributes
         LDX $00         ; Index: 0
         REP #$20        ; 16-bit A
C303AF:  LDA.L C304D1,X  ; Tile number
         CLC             ; Prepare ADC
         ADC $E7         ; Add attributes
         STA $7E9F19,X   ; Save in RAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0038      ; Done 28 tiles?
         BNE C303AF      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Prepare to and draw a menu window
C303C4:  LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
C303C8:  STY $E7         ; Set src LBs
         LDX $00         ; ...
         TXY             ; Index: 0
         REP #$20        ; 16-bit A
         LDA [$E7],Y     ; Tilemap ptr
         STA $EB         ; Set position
         INY             ; Index +1
         INY             ; Index +1
         LDA [$E7],Y     ; Window size
         STA $E0         ; Memorize it
         SEP #$20        ; 8-bit A
         STA $E2         ; ...
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDX $00         ; Clear X
         TXY             ; Clear Y...
         SEP #$10        ; 8-bit X, Y
         LDX $E0         ; Inner width
         LDY $E1         ; Inner height
         REP #$10        ; 16-bit X, Y
         STX $EF         ; Set 16b width
         STY $F1         ; Set 16b height
         REP #$20        ; 16-bit A
         JSR C303F8      ; Draw window
         SEP #$20        ; 8-bit A
         RTS

; Draw a menu window
C303F8:  JSR C30426      ; Draw top row
         LDX $00         ; Inner row: 1st
         LDY #$0040      ; Skipped rows: 1
         STY $F3         ; Init map index
C30402:  PHX             ; Save row number
         TXA             ; Move it to A
         AND #$0003      ; Get pattern row
         ASL A           ; Double it
         TAX             ; Index it
         JSR (C3041E,X)  ; Draw inner row
         LDA $F3         ; Tilemap index
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         STA $F3         ; Save changes
         TAY             ; Index it
         PLX             ; Row number
         INX             ; Row number +1
         CPX $F1         ; At last row?
         BNE C30402      ; Loop if not
         JMP C3043E      ; Draw last row

; Jump table for the above
C3041E:  dw C30454       ; Pattern row 1 of 4
         dw C3045E       ; Pattern row 2 of 4
         dw C3046B       ; Pattern row 3 of 4
         dw C30478       ; Pattern row 4 of 4

; Draw window's upper row
C30426:  LDY $00         ; Map index: 0
         JSR C3048B      ; Define pattern
         LDA $7E9F49     ; NW corner tile
         STA $E3         ; Set first tile
         LDA $7E9F4B     ; NE corner tile
         STA $E5         ; Set final tile
         LDX #$0020      ; Base tile index
         STX $E0         ; Memorize it
         BRA C304AB      ; Draw top row

; Draw window's lower row
C3043E:  JSR C3048B      ; Define pattern
         LDA $7E9F4D     ; SW corner tile
         STA $E3         ; Set first tile
         LDA $7E9F4F     ; SE corner tile
         STA $E5         ; Set final tile
         LDX #$0024      ; Base tile index
         STX $E0         ; Memorize it
         BRA C304AB      ; Draw bottom row

; Draw inner window row, pattern part 1 of 4
C30454:  JSR C30485      ; Define pattern
         JSR C30491      ; Get side tiles
         STZ $E0         ; Base tile index
         BRA C304AB      ; Draw inner row

; Draw inner window row, pattern part 2 of 4
C3045E:  JSR C30485      ; Define pattern
         JSR C3049E      ; Get side tiles
         LDX #$0008      ; Base tile index
         STX $E0         ; Memorize it
         BRA C304AB      ; Draw inner row

; Draw inner window row, pattern part 3 of 4
C3046B:  JSR C30485      ; Define pattern
         JSR C30491      ; Get side tiles
         LDX #$0010      ; Base tile index
         STX $E0         ; Memorize it
         BRA C304AB      ; Draw inner row

; Draw inner window row, pattern part 4 of 4
C30478:  JSR C30485      ; Define pattern
         JSR C3049E      ; Get side tiles
         LDX #$0018      ; Base tile index
         STX $E0         ; Memorize it
         BRA C304AB      ; Draw inner row

; Set pattern width for inner window tiles
C30485:  LDX #$0003      ; Tiles: 4
         STX $F5         ; Set pattern width
         RTS

; Set pattern width for top or bottom window border
C3048B:  LDX #$0001      ; Tiles: 2
         STX $F5         ; Set pattern width
         RTS

; Get window side tiles for odd-numbered pattern row
C30491:  LDA $7E9F41     ; Left border A
         STA $E3         ; Set first tile
         LDA $7E9F43     ; Right border A
         STA $E5         ; Set final tile
         RTS

; Get window side tiles for even-numbered pattern row
C3049E:  LDA $7E9F45     ; Left border B
         STA $E3         ; Set first tile
         LDA $7E9F47     ; Right border B
         STA $E5         ; Set final tile
         RTS

; Draw a row of window tiles
C304AB:  LDX $00         ; Inner col: 1st
         LDA $E3         ; Leftmost tile
         STA [$EB],Y     ; Add to tilemap
         INY             ; Map index +1
         INY             ; Map index +1
C304B3:  PHX             ; Save column
         TXA             ; Move it to A
         AND $F5         ; Stay in pattern
         ASL A           ; Double it
         CLC             ; ...
         ADC $E0         ; Add base index
         TAX             ; Index sum
         LDA $7E9F19,X   ; Inner tile
         PLX             ; Column number
         CPX $EF         ; At last one?
         BEQ C304CC      ; Branch if so
         STA [$EB],Y     ; Add tile to map
         INY             ; Map index +1
         INY             ; Map index +1
         INX             ; Column +1
         BRA C304B3      ; Do next tile
C304CC:  LDA $E5         ; Rightmost tile
         STA [$EB],Y     ; Add to tilemap
         RTS

; Window tile numbers
C304D1:  dw $0180        ; Inner part 1,1
         dw $0181        ; Inner part 1,2
         dw $0182        ; Inner part 1,3
         dw $0183        ; Inner part 1,4
         dw $0184        ; Inner part 2,1
         dw $0185        ; Inner part 2,2
         dw $0186        ; Inner part 2,3
         dw $0187        ; Inner part 2,4
         dw $0188        ; Inner part 3,1
         dw $0189        ; Inner part 3,2
         dw $018A        ; Inner part 3,3
         dw $018B        ; Inner part 3,4
         dw $018C        ; Inner part 4,1
         dw $018D        ; Inner part 4,2
         dw $018E        ; Inner part 4,3
         dw $018F        ; Inner part 4,4
         dw $0191        ; Upper border A
         dw $0192        ; Upper border B
         dw $0199        ; Lower border A
         dw $019A        ; Lower border B
         dw $0194        ; Left border A
         dw $0195        ; Right border A
         dw $0196        ; Left border B
         dw $0197        ; Right border B
         dw $0190        ; NW corner
         dw $0193        ; NE corner
         dw $0198        ; SW corner
         dw $019B        ; SE corner

; Draw 3 digits (16-bit number)
C30509:  LDY #$0005      ; Digits: 5
         STY $E0         ; Set counter
         LDY #$0002      ; Skipped: 2
         BRA C3054A      ; Draw text

; Draw 4 digits
C30513:  LDY #$0005      ; Digits: 5
         STY $E0         ; Set counter
         LDY #$0001      ; Skipped: 1
         BRA C3054A      ; Draw text

; Draw 5 digits
C3051D:  LDY #$0005      ; Digits: 5
         STY $E0         ; Set counter
         LDY $00         ; Skipped: 0
         BRA C3054A      ; Draw text

; Draw 8 digits
C30526:  LDY #$0008      ; Digits: 8
         STY $E0         ; Set counter
         LDY $00         ; Skipped: 0
         BRA C3054A      ; Draw text

; Draw 7 digits
C3052F:  LDY #$0008      ; Digits: 8
         STY $E0         ; Set counter
         LDY #$0001      ; Skipped: 1
         BRA C3054A      ; Draw text

; Draw 2 digits
C30539:  LDY #$0003      ; Digits: 3
         STY $E0         ; Set counter
         LDY #$0001      ; Skipped: 1
         BRA C3054A      ; Draw text

; Draw 3 digits (8-bit number)
C30543:  LDY #$0003      ; Digits: 3
         STY $E0         ; Set counter
         LDY $00         ; Skipped: 0
C3054A:  STX $EB         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
         TYX             ; Digit index
         LDY $00         ; Map index: 0
C30553:  LDA $F7,X       ; Digit char
         STA [$EB],Y     ; Add to tilemap
         INY             ; Map index +1
         LDA $29         ; Palette, etc.
         STA [$EB],Y     ; Set attributes
         INY             ; Map index +1
         INX             ; Digit index +1
         CPX $E0         ; More digits?
         BNE C30553      ; Loop if so
         RTS

; Convert 8-bit number into text, blank leading zeroes
C30563:  JSR C3057C      ; Turn into text
         LDY $00         ; 1st: Hundreds
         LDX #$0002      ; Digits left: 2
C3056B:  LDA $00F7,Y     ; Digit char
         CMP #$53        ; Zero?			=== SNES: Different tile number
         BNE C3057B      ; Exit if not
         LDA #$FF        ; Space char
         STA $00F7,Y     ; Replace digit
         INY             ; Point to next
         DEX             ; One less left
         BNE C3056B      ; Loop till last
C3057B:  RTS

; Convert 8-bit number into text, retain leading zeroes
C3057C:  STA $E0         ; Save number
         LDA #$03        ; Digits: 3
         STA $E4         ; Set counter
         LDY $00         ; RAM index: 0
         TYX             ; ROM index: 0
C30585:  STZ $E1         ; Digit: 0
         LDA.L C305AE,X  ; Power of 10
         INX             ; ROM index +1
         STA $E3         ; Save power
C3058E:  LDA $E0         ; Revised number
         SEC             ; Prepare SBC
         SBC $E3         ; Deduct power
         BCC C3059B      ; Branch if < 0
         STA $E0         ; Save changes
         INC $E1         ; Digit +1
         BRA C3058E      ; Loop
C3059B:  CLC             ; ...
         ADC $ED         ; ...
         STA $F3         ; ...
         LDA $E1         ; Digit
         CLC             ; Prepare ADC
         ADC #$53        ; Turn into text		=== SNES: Different base tile number
         STA $00F7,Y     ; Set digit char
         INY             ; Point to next
         DEC $E4         ; One less left
         BNE C30585      ; Loop till last
         RTS

; Powers of ten for the above
C305AE:  db $64          ; 100
         db $0A          ; 10
         db $01          ; 1

; Convert 16-bit number into text, blank leading zeroes
C305B1:  LDA #$05        ; Digits: 5
         STA $E0         ; Set counter
         LDY $00         ; RAM index: 0
         TYX             ; ROM index: 0
C305B8:  REP #$20        ; 16-bit A
         LDA.L C305FB,X  ; Power of 10
         INX             ; ROM index +1
         INX             ; ROM index +1
         STA $ED         ; Save power
         STZ $EB         ; Digit: 0
C305C4:  SEC             ; Prepare SBC
         LDA $F3         ; Revised number
         SBC $ED         ; Deduct power
         BCC C305D1      ; Branch if < 0
         STA $F3         ; Save changes
         INC $EB         ; Digit +1
         BRA C305C4      ; Loop

; Fork: Convert digit into text
C305D1:  CLC             ; ...
         ADC $ED         ; ...
         STA $F3         ; ...
         SEP #$20        ; 8-bit A
         LDA $EB         ; Digit
         CLC             ; ...
         ADC #$53        ; Turn into text		=== SNES: Different base tile number
         STA $00F7,Y     ; Set digit char
         INY             ; RAM index +1
         DEC $E0         ; One less digit
         BNE C305B8      ; Loop till last

; Fork: Blank leading zeroes
C305E5:  LDY $00         ; Index: 0
         LDX #$0004      ; Digits: 4
C305EA:  LDA $00F7,Y     ; Digit char
         CMP #$53        ; Zero?			=== SNES: Different tile number
         BNE C305FA      ; Exit if not
         LDA #$FF        ; Space char
         STA $00F7,Y     ; Replace digit
         INY             ; Point to next
         DEX             ; One less left
         BNE C305EA      ; Loop till last
C305FA:  RTS

; Powers of ten for the above
C305FB:  dw $2710        ; 10000
         dw $03E8        ; 1000
         dw $0064        ; 100
         dw $000A        ; 10
         dw $0001        ; 1

; Convert 24-bit number into text, blank leading zeroes
C30605:  STZ $F4         ; Number HB: 0
         LDA #$08        ; Digits: 8
         STA $E0         ; Set counter
         LDY $00         ; RAM index: 0
         TYX             ; ROM index: 0
C3060E:  REP #$20        ; 16-bit A
         STZ $EB         ; Digit: 0
C30612:  SEC             ; Prepare SBC
         LDA $F1         ; Number LBs
         SBC.L C30661,X  ; Deduct power's
         STA $F1         ; Save changes
         LDA $F3         ; Number HBs
         SBC.L C30671,X  ; Deduct power's
         STA $F3         ; Save changes
         BCC C30629      ; Branch if < 0
         INC $EB         ; Digit +1
         BRA C30612      ; Loop

; Fork: Cancel subtraction and convert digit
C30629:  LDA $F1         ; Number LBs
         CLC             ; ...
         ADC.L C30661,X  ; Reverse SBC
         STA $F1         ; Save changes
         LDA $F3         ; Number HBs
         ADC.L C30671,X  ; Reverse SBC
         STA $F3         ; Save changes
         SEP #$20        ; 8-bit A
         LDA $EB         ; Digit
         CLC             ; Prepare ADC
         ADC #$53        ; Turn into text		=== SNES: Different base tile number
         STA $00F7,Y     ; Set digit char
         INY             ; RAM index +1
         INX             ; ROM index +1
         INX             ; ROM index +1
         DEC $E0         ; One less digit
         BNE C3060E      ; Loop till last

; Fork: Blank leading zeroes
C3064B:  LDY $00         ; Index: 0
         LDX #$0007      ; Digits: 7
C30650:  LDA $00F7,Y     ; Digit char
         CMP #$53        ; Zero?			=== SNES: Different tile number
         BNE C30660      ; Exit if not
         LDA #$FF        ; Space char
         STA $00F7,Y     ; Replace digit
         INY             ; Point to next
         DEX             ; One less left
         BNE C30650      ; Loop till last
C30660:  RTS

; Powers of ten, low bytes
C30661:  dw $9680        ; 10000000
         dw $4240        ; 1000000
         dw $86A0        ; 100000
         dw $2710        ; 10000
         dw $03E8        ; 1000
         dw $0064        ; 100
         dw $000A        ; 10
         dw $0001        ; 1

; Powers of ten, high bytes
C30671:  dw $0098        ; 10000000
         dw $000F        ; 1000000
         dw $0001        ; 100000
         dw $0000        ; 10000
         dw $0000        ; 1000
         dw $0000        ; 100
         dw $0000        ; 10
         dw $0000        ; 1

; Load navigation parameters for menu area
C30681:  LDA #$C3        ; Bank: C3
         STA $ED         ; Set src HB
C30685:  STY $EB         ; Set src LBs
         LDY $00         ; Index: 0
         LDA [$EB],Y     ; Wrap flags
         STA $59         ; Save in RAM
         INY             ; Index +1
         REP #$20        ; 16-bit A
         STZ $51         ; See C3/0758...
         LDA [$EB],Y     ; Initial spot
         STA $4D         ; Set cursor's
         INY             ; Index +1
         INY             ; Index +1
         LDA [$EB],Y     ; Rows, columns
         STA $53         ; Set boundaries
         STZ $4F         ; List col/row: 1
         SEP #$20        ; 8-bit A
         RTS

; Target party's leader
C306A1:  TDC             ; Clear A
         TAY             ; Member: 1st
C306A3:  TYA             ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $85,X       ; Empty slot?
         BNE C306B2      ; Exit if not
         INC $4E         ; Cursor row +1
         INY             ; Member slot +1
         CPY #$0004      ; Done all 4?
         BNE C306A3      ; Loop if not
C306B2:  RTS

; Set address to table of cursor coordinates
C306B3:  STY $E7         ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         RTS

; Position cursor in party area of Lineup menu
C306BA:  JSR C306B3      ; Set source
         JSR C306D3      ; Set list slot
         JMP C30748      ; Set coords

; Position cursor in unscrollable area
C306C3:  JSR C306B3      ; Set source
C306C6:  JSR C306FA      ; Set list slot
         BRA C30748      ; Set coords

; Position cursor in scrollable list
C306CB:  JSR C306B3      ; Set source
         JSR C30721      ; Set list slot
         BRA C30748      ; Set coords

; Set cursor's slot position in party area of Lineup menu
C306D3:  PHB             ; Save DB
         LDA #$00        ; Clear A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
C306D8:  LDA $004212     ; PPU status
         AND #$40        ; H-Blank?
         BEQ C306D8      ; Loop if not
         LDA $54         ; Number of rows
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA $4D         ; Cursor column
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2134       ; Product LB
         CLC             ; Prepare ADC
         ADC $4E         ; Add cursor row
         STA $4B         ; Set cursor slot
         PLB             ; Restore DB
         RTS

; Set cursor's slot position in unscrollable area
C306FA:  PHB             ; Save DB
         LDA #$00        ; Clear A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
C306FF:  LDA $004212     ; PPU status
         AND #$40        ; H-Blank?
         BEQ C306FF      ; Loop if not
         LDA $53         ; Column count
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA $4E         ; Cursor row
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2134       ; Product LB
         CLC             ; Prepare ADC
         ADC $4D         ; Add cursor col
         STA $4B         ; Set cursor slot
         PLB             ; Restore DB
         RTS

; Set cursor's slot position in scrollable list
C30721:  PHB             ; Save DB
         LDA #$00        ; Clear A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
C30726:  LDA $004212     ; PPU status
         AND #$40        ; H-Blank?
         BEQ C30726      ; Loop if not
         LDA $53         ; Column count
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA $50         ; List row
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2134       ; Product LB
         CLC             ; Prepare ADC
         ADC $4F         ; Add list column
         STA $4B         ; Set cursor slot
         PLB             ; Restore DB
         RTS

; Set cursor's position in pixels
C30748:  PHB             ; Save DB
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDA $53         ; Column count
         DEC A           ; Adjust value
         CMP $4D         ; In range now?
         BCS C30760      ; Branch if so

; Fork: Invalid column (unused)
C30754:  LDA $53         ; ...
         DEC A           ; ...
         SEC             ; Prepare SBC
         SBC $51         ; Minus 0...
         STA $E0         ; Use col qty -1
         STA $E2         ; Use last column
         BRA C30768      ; Validate row

; Fork: Valid column
C30760:  LDA $53         ; Column count
         STA $E0         ; Memorize it
         LDA $4D         ; Cursor column
         STA $E2         ; Memorize it

; Fork: Validate row
C30768:  LDA $54         ; Number of rows
         DEC A           ; Adjust value
         CMP $4E         ; In range now?
         BCS C30779      ; Branch if so

; Fork: Invalid row (unused)
C3076F:  LDA $54         ; ...
         DEC A           ; ...
         SEC             ; Prepare SBC
         SBC $52         ; Minus 0...
         STA $E1         ; Force last row
         BRA C3077D      ; Skip 2 lines

; Fork: Valid row
C30779:  LDA $4E         ; Cursor row
         STA $E1         ; Memorize it
C3077D:  LDA $004212     ; PPU status
         AND #$40        ; H-Blank?
         BEQ C3077D      ; Loop if not
         LDA $E0         ; Number of columns
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA $E1         ; Cursor row
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2134       ; Product LB
         CLC             ; Prepare ADC
         ADC $E2         ; Add column
         ASL A           ; Double it
         XBA             ; Switch to HB
         LDA $00         ; Clear it
         XBA             ; Switch to LB
         TAY             ; Index it
         LDA [$E7],Y     ; X position
         STA $55         ; Set cursor's
         STZ $56         ; Clear HB
         INY             ; Index +1
         LDA [$E7],Y     ; Y position
         STA $57         ; Set cursor's
         STZ $58         ; Clear HB
         PLB             ; Restore DB
         RTS

; Handle D-Pad for unscrollable list
C307B0:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C307D3      ; Branch if not
         LDA $4E         ; On top row?
         BNE C307CB      ; Go up if not
         LDA $59         ; Wrap flags
         AND #$01        ; No V-Wrap?
         BNE C30832      ; Exit if so
         LDA $54         ; Bottom row
         DEC A           ; Adjust value
         STA $4E         ; Set cursor row
         JSR C30F0E      ; Sound: Cursor
         JMP C30832      ; Exit

; Fork: Move cursor up
C307CB:  DEC $4E         ; Cursor row -1
         JSR C30F0E      ; Sound: Cursor
         JMP C30832      ; Exit

; Fork: Handle down
C307D3:  LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C307F6      ; Branch if not
         LDA $54         ; Bottom row
         DEC A           ; Adjust value
         CMP $4E         ; Cursor's there?
         BNE C307EE      ; Go down if not
         LDA $59         ; Wrap flags
         AND #$01        ; No V-Wrap?
         BNE C30832      ; Exit if so
         STZ $4E         ; Cursor row: 1
         JSR C30F0E      ; Sound: Cursor
         JMP C30832      ; Exit

; Fork: Move cursor down
C307EE:  INC $4E         ; Cursor row +1
         JSR C30F0E      ; Sound: Cursor
         JMP C30832      ; Exit

; Fork: Handle left
C307F6:  LDA $0B         ; Semi-auto keys
         BIT #$02        ; Pushing left?
         BEQ C30815      ; Branch if not
         LDA $4D         ; On first column?
         BNE C3080E      ; Go left if not
         LDA $59         ; H-Wrap disabled?
         BMI C30832      ; Exit if so
         LDA $53         ; Last column
         DEC A           ; Adjust value
         STA $4D         ; Set cursor column
         JSR C30F0E      ; Sound: Cursor
         BRA C30832      ; Exit

; Fork: Move cursor left
C3080E:  DEC $4D         ; Cursor column -1
         JSR C30F0E      ; Sound: Cursor
         BRA C30832      ; Exit

; Fork: Handle right
C30815:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C30832      ; Exit if not
         LDA $53         ; Last column
         DEC A           ; Adjust value
         CMP $4D         ; Cursor's there?
         BNE C3082D      ; Go right if not
         LDA $59         ; H-Wrap disabled?
         BMI C30832      ; Exit if so
         STZ $4D         ; Cursor column: 1
         JSR C30F0E      ; Sound: Cursor
         BRA C30832      ; Exit

; Fork: Move cursor right
C3082D:  INC $4D         ; Cursor column +1
         JSR C30F0E      ; Sound: Cursor
C30832:  RTS

; Queue movable cursor's OAM function
C30833:  LDA #$01        ; Min slot: 8
         LDY #C3083B     ; C3/083B
         JMP C311DE      ; Queue OAM fn

; Update movable cursor's sprite
C3083B:  TAX             ; Index mode
         JMP (C3083F,X)  ; Handle mode

; Jump table for the above
C3083F:  dw C30843       ; Initialize cursor
         dw C3085F       ; Sustain cursor

; Mode 0: Initialize cursor
C30843:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #C30912     ; Anim table ptr
         STA $32C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         INC $3649,X     ; Mode +1
         LDA #$01        ; Pans with BG1
         STA $364A,X     ; Set sprite flags

; Mode 1: Sustain cursor
C3085F:  LDA $46         ; Menu flags
         AND #$06        ; Remove cursors?
         BEQ C30880      ; Delete if so
         LDA $45         ; Menu flags
         BIT #$04        ; Hide cursor?
         BEQ C3087E      ; Exit if so
         LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $55         ; Cursor's X
         STA $33CA,X     ; Set sprite's
         LDA $57         ; Cursor's Y
         STA $344A,X     ; Set sprite's
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
C3087E:  SEC             ; Set to requeue
         RTS             ; Exit
C30880:  CLC             ; Set to dequeue
         RTS

; Update blinking cursor marking prior choice
C30882:  TAX             ; Index mode
         JMP (C30886,X)  ; Handle mode

; Jump table for the above
C30886:  dw C3088E       ; Initialize cursor
         dw C308AE       ; Sustain cursor V1
         dw C3088E       ; Initialize cursor
         dw C308EC       ; Sustain cursor V2

; Mode 0 or 2: Initialize cursor
C3088E:  LDX $2D         ; Queue index
         LDA #$01        ; Blinkers V1: On
         TSB $46         ; Set menu flag
         REP #$20        ; 16-bit A
         LDA #C3091B     ; Anim table ptr
         STA $32C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         LDA #$01        ; Pans with BG1
         STA $364A,X     ; Set sprite flags
         INC $3649,X     ; Mode +1

; Mode 1: Sustain cursor not in party area of Lineup menu
C308AE:  LDA $46         ; Menu flags
         BIT #$01        ; Remove blinkers?
         BEQ C308EA      ; Delete if so
         LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $41         ; List V-Speed
         EOR #$FFFF      ; Invert it
         INC A           ; Add 1
         CLC             ; Prepare ADC
         ADC $344A,X     ; Add cursor's Y
         STA $344A,X     ; Set cursor's Y
         SEP #$20        ; 8-bit A
         LDA $46         ; Menu flags
         AND #$C0        ; Scrollable list?
         BEQ C308E5      ; Display if not

; Fork: Item menu					%%% SNES: Most code differs to account for single column
C308CD:  LDA $28         ; Blinker's slot
         AND #$FE        ; Get row x2
         INC A           ; Add 1
         STA $E0         ; Memorize it
         LDA $4A         ; Top onscreen row
         ASL A           ; Double it
         CLC             ; Prepare ADC
         ADC #$13        ; Get bottom row
         CMP $E0         ; Blinker's below?
         BCC C308E8      ; Blank if so
         LDA $4A         ; Top onscreen row
         ASL A           ; Double it
         CMP $E0         ; Blinker's above?
         BCS C308E8      ; Blank if so
C308E5:  JSR C3128C      ; Define OAM
C308E8:  SEC             ; Set to requeue
         RTS             ; Exit
C308EA:  CLC             ; Set to dequeue
         RTS

; Mode 3: Sustain cursor in party area of Lineup menu
C308EC:  LDA $46         ; Menu flags
         BIT #$01        ; Remove blinkers?
         BEQ C308EA      ; Delete if so
         LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $97         ; Always 0...
         EOR #$FFFF      ; Invert it
         INC A           ; Add 1
         CLC             ; Prepare ADC
         ADC $33CA,X     ; Add cursor's X
         STA $33CA,X     ; Set cursor's X
         SEP #$20        ; 8-bit A
         LDY $33CA,X     ; Cursor's X
         CPY #$0100      ; Past east edge?
         BCS C30910      ; Blank if so
         JSR C3128C      ; Define OAM
C30910:  SEC             ; Set to requeue
         RTS

; Animation table for main cursor
C30912:  dw C30915       ; Sprite 1
         db $FE          ; Freeze

; OAM for hand cursor
C30915:  db $01          ; Tiles: 1
         dw $0080        ; 16x16, X+0, Y+0
         dw $3E00        ; Tile 0, pal 7, prio 3

; OAM for blanking cursor
C3091A:  db $00          ; Tiles: 0

; Animation table for blinking cursor
C3091B:  dw C30915       ; Show cursor
         db $02          ; Frames: 2
         dw C3091A       ; Hide cursor
         db $02          ; Frames: 2
         dw C30915       ; Bogus...
         db $FF          ; Loop

; Create a blinking cursor by every portrait
C30924:  TDC             ; Clear A
         TAX             ; Member: 1st
C30926:  LDA $85,X       ; Nobody here?
         BEQ C3094E      ; Skip if so
         PHX             ; Save index
         LDA #$01        ; Min slot: 8
         LDY #C30956     ; C3/0956
         JSR C311DE      ; Queue OAM fn
         TXY             ; Queue index
         PLX             ; Member index
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDA $85,X       ; X position
         STA $33CA,Y     ; Set cursor's
         LDA $86,X       ; Y position
         STA $344A,Y     ; Set cursor's
         TDC             ; Clear A
         STA $33CB,Y     ; ...
         STA $344B,Y     ; ...
         LDA #$00        ; ...
         PHA             ; Put on stack
         PLB             ; Set DB to 0
C3094E:  INX             ; Char index +1
         INX             ; Char index +1
         CPX #$0008      ; Done 4 chars?
         BNE C30926      ; Loop if not
         RTS

; Update blinking cursor not marking a prior choice
C30956:  TAX             ; Index mode
         JMP (C3095A,X)  ; Handle mode

; Jump table for the above
C3095A:  dw C3095E       ; Initialize cursor
         dw C3097E       ; Sustain cursor

; Mode 0: Initialize cursor
C3095E:  LDX $2D         ; Queue index
         LDA #$08        ; Blinkers V2: On
         TSB $46         ; Set menu flag
         REP #$20        ; 16-bit A
         LDA #C3091B     ; Anim table ptr
         STA $32C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         INC $3649,X     ; Mode +1
         LDA #$01        ; Pans with BG1
         STA $364A,X     ; Set sprite flags

; Mode 1: Sustain cursor
C3097E:  LDA $46         ; Menu flags
         BIT #$08        ; Remove blinkers?
         BEQ C3098B      ; Delete if so
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C3098B:  CLC             ; Set to dequeue
         RTS

; Update scrollbar animation index
C3098D:  LDA #$C0        ; Flashing: 2-ways
         TSB $46         ; Initialize index
         LDA $4A         ; At top of list?
         BNE C30999      ; Branch if not
         LDA #$40        ; Flashing: Down
         TRB $46         ; Update index
C30999:  LDA $4A         ; Scroll position
         CMP $5C         ; At very bottom?
         BNE C309A3      ; Exit if not
         LDA #$80        ; Flashing: Up
         TRB $46         ; Update index
C309A3:  RTS

; Create a scrollbar on right side of screen
C309A4:  LDA #$03        ; Min slot: 24
         LDY #C309CC     ; C3/09CC
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA #$00E8      ; X: 232
         STA $7E33CA,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Create a scrollbar in middle of screen
C309B8:  LDA #$03        ; Min slot: 24
         LDY #C309CC     ; C3/09CC
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA #$0070      ; X: 112			=== SNES: 120
         STA $7E33CA,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Update scrollbar
C309CC:  TAX             ; Index mode
         JMP (C309D0,X)  ; Handle mode

; Jump table for the above
C309D0:  dw C309D4       ; Initialize scrollbar
         dw C309EF       ; Sustain scrollbar

; Mode 0: Initialize scrollbar
C309D4:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #C30A4E     ; C3/0A4E
         STA $32C9,X     ; Init anim ptr
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer
         LDA #$C0        ; Flash: Both ways
         TSB $46         ; Init anim index

; Mode 1: Sustain scrollbar
C309EF:  LDA $46         ; Menu flags
         AND #$C0        ; Hide scrollbar?
         BEQ C30A44      ; Delete if so
         LDX $2D         ; Queue index
         JSR C3098D      ; Set anim index
C309FA:  LDA $004212     ; PPU status
         AND #$40        ; H-Blank?
         BEQ C309FA      ; Loop if not
         LDA $354A,X     ; V-Speed LB
         STA $00211B     ; Set matrix A LB
         LDA $354B,X     ; V-Speed HB
         STA $00211B     ; Set matrix A HB
         LDA $4A         ; Scroll position
         STA $00211C     ; Set matrix B
         STA $00211C     ; ...









         TDC             ; Clear A
         LDA $002135     ; Product MB
         REP #$21        ; 16-bit A; C-


         ADC $34CA,X     ; Add base Y
         STA $344A,X     ; Set bar's Y
         SEP #$20        ; 8-bit A

         LDA $46         ; Menu flags
         AND #$C0        ; Anim index
         LSR A           ; Put in b5-b6
         LSR A           ; Put in b4-b5
         LSR A           ; Put in b3-b4
         LSR A           ; Put in b2-b3
         LSR A           ; Put in b1-b2
         TXY             ; Queue index
         TAX             ; Anim index
         REP #$20        ; 16-bit A
         LDA.L C30A46,X  ; Anim pointer
         STA $32C9,Y     ; Set sprite's
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C30A44:  CLC             ; Set to dequeue
         RTS

; Pointers to scrollbar animation tables
C30A46:  dw C30A4E       ; Bogus...
         dw C30A57       ; Flashing up
         dw C30A60       ; Flashing down
         dw C30A4E       ; Flashing both ways

; Animation table for scrollbar flashing both ways
C30A4E:  dw C30A69       ; Flash neither
         db $10          ; Frames: 16
         dw C30A72       ; Flash both
         db $10          ; Frames: 16
         dw C30A69       ; Bogus...
         db $FF          ; Loop

; Animation table for scrollbar pointing up
C30A57:  dw C30A69       ; Flash neither
         db $10          ; Frames: 16
         dw C30A7B       ; Flash highest
         db $10          ; Frames: 16
         dw C30A69       ; Bogus...
         db $FF          ; Loop

; Animation table for scrollbar pointing down
C30A60:  dw C30A69       ; Flash neither
         db $10          ; Frames: 16
         dw C30A84       ; Flash lowest
         db $10          ; Frames: 16
         dw C30A69       ; Bogus...
         db $FF          ; Loop

; OAM for non-flashing scrollbar
C30A69:  db $02          ; Tiles: 2
         dw $0000,$3E02  ; ^: White
         dw $0800,$BE02  ; v: White

; OAM for scrollbar flashing both ways
C30A72:  db $02          ; Tiles: 2
         dw $0000,$3E12  ; ^: Black
         dw $0800,$BE12  ; v: Black

; OAM for scrollbar pointing up
C30A7B:  db $02          ; Tiles: 2
         dw $0000,$3E12  ; ^: Black
         dw $0800,$BE02  ; v: White

; OAM for scrollbar pointing down
C30A84:  db $02          ; Tiles: 2
         dw $0000,$3E02  ; ^: White
         dw $0800,$BE12  ; v: Black

; Create portrait for member 1
C30A8D:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         TXA             ; Queue index
         STA $60         ; Set sprite's
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDY $00         ; Member slot: 1
         JSR C30B5C      ; Set base X loc
         LDY $00         ; Face slot: 1
         JSR C30B37      ; Load anim ptr
         REP #$20        ; 16-bit A
         LDA #$0015      ; Base Y: 21
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer
         PLB             ; Restore DB
         RTS

; Create portrait for member 2
C30AB6:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         TXA             ; Queue index
         STA $61         ; Set sprite's
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDY #$0001      ; Member slot: 2
         JSR C30B5C      ; Set base X loc
         LDY #$0001      ; Face slot: 2
         JSR C30B37      ; Load anim ptr
         REP #$20        ; 16-bit A
         LDA #$0045      ; Base Y: 69
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer
         PLB             ; Restore DB
         RTS

; Create portrait for member 3
C30AE1:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         TXA             ; Queue index
         STA $62         ; Set sprite's
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDY #$0002      ; Member slot: 3
         JSR C30B5C      ; Set base X loc
         LDY #$0002      ; Face slot: 3
         JSR C30B37      ; Load anim ptr
         REP #$20        ; 16-bit A
         LDA #$0075      ; Base Y: 117
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer
         PLB             ; Restore DB
         RTS

; Create portrait for member 4
C30B0C:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         TXA             ; Queue index
         STA $63         ; Set sprite's
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDY #$0003      ; Member slot: 4
         JSR C30B5C      ; Set base X loc
         LDY #$0003      ; Face slot: 4
         JSR C30B37      ; Load anim ptr
         REP #$20        ; 16-bit A
         LDA #$00A5      ; Base Y: 165
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer
         PLB             ; Restore DB
         RTS

; Load pointer to animation table for portrait
C30B37:  PHX             ; Save index
         PHX             ; Save index
         TYX             ; Member slot
         LDA $75,X       ; Party info
         AND #$18        ; Roster slot
         LSR A           ; Put in b2-b3
         LSR A           ; Put in b1-b2
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C30B54,X  ; Anim table ptr
         PLY             ; Queue index
         STA $32C9,Y     ; Set ptr LBs
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,Y     ; Set ptr HB
         PLX             ; Queue index
         RTS

; Pointers to portrait animation tables
C30B54:  dw C30BF7       ; Portrait A
         dw C30C2F       ; Portrait B
         dw C30C67       ; Portrait C
         dw C30C9F       ; Portrait D

; Set portrait's base X position based on actor's row
C30B5C:  PHX             ; Queue index
         TYX             ; Member slot
         LDA #$02        ; Portrait bit
         BIT $45         ; Ignore row?
         BNE C30B6A      ; Branch if so
         LDA $75,X       ; Party info
         BIT #$20        ; In back row?
         BEQ C30B71      ; Branch if not
C30B6A:  REP #$20        ; 16-bit A
         LDA #$001A      ; Base X: 26
         BRA C30B76      ; Skip 2 lines
C30B71:  REP #$20        ; 16-bit A
         LDA #$000E      ; Base X: 15
C30B76:  PLX             ; Queue index
         STA $33CA,X     ; Set sprite's X
         SEP #$20        ; 8-bit A
         RTS

; Update actor portrait
C30B7D:  TAX             ; Index mode
         JMP (C30B81,X)  ; Handle mode

; Jump table for the above
C30B81:  dw C30B8B       ; Set to pan with BG1
         dw C30B95       ; Sustain portrait
         dw C30BA3       ; Set to shift right
         dw C30BB7       ; Set to shift left
         dw C30BC9       ; Shift left or right

; Mode 0: Set to pan with BG1
C30B8B:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$01        ; Pans with BG1
         STA $364A,X     ; Set sprite flags

; Mode 1: Sustain portrait
C30B95:  LDX $2D         ; Queue index
         LDA $35C9,X     ; Hide portrait?
         BMI C30BA1      ; Delete if so
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C30BA1:  CLC             ; Set to dequeue
         RTS

; Mode 2: Set to shift right
C30BA3:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #$0001      ; H-Speed: 1
         STA $34CA,X     ; Set sprite's
         LDA #$000C      ; Frames: 12
         STA $3349,X     ; Set shift timer
         SEP #$20        ; 8-bit A
         BRA C30BC9      ; Shift once

; Mode 3: Set to shift left
C30BB7:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #$FFFF      ; H-Speed: -1
         STA $34CA,X     ; Set sprite's
         LDA #$000C      ; Frames: 12
         STA $3349,X     ; Set shift timer
         SEP #$20        ; 8-bit A

; Mode 4: Shift left or right
C30BC9:  LDX $2D         ; Queue index
         LDA #$04        ; Mode: 4
         STA $3649,X     ; Set sprite's
         REP #$20        ; 16-bit A
         LDA $3349,X     ; Timer expired?
         BEQ C30BEB      ; Freeze if so
         LDA $34CA,X     ; H-Speed
         CLC             ; Prepare ADC
         ADC $33CA,X     ; Add base X
         STA $33CA,X     ; Set sprite's
         DEC $3349,X     ; Timer -1
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Fork: Set to stop moving
C30BEB:  SEP #$20        ; 8-bit A
         LDA #$01        ; Mode: 1
         STA $3649,X     ; Set sprite's
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Animation table for portrait A
C30BF7:  dw C30BFA       ; Show portrait
         db $FE          ; Freeze

; OAM for portrait A
C30BFA:  db $0D          ; Tiles: 13
         dw $0080,$2060  ; Tile 1
         dw $0090,$2062  ; Tile 2
         dw $1080,$2064  ; Tile 3
         dw $1090,$2066  ; Tile 4
         dw $0020,$2068  ; Tile 5
         dw $0820,$2069  ; Tile 6
         dw $1020,$206A  ; Tile 7
         dw $1820,$206B  ; Tile 8
         dw $2020,$206C  ; Tile 9
         dw $2000,$206D  ; Tile 10
         dw $2008,$206E  ; Tile 11
         dw $2010,$206F  ; Tile 12
         dw $2018,$2078  ; Tile 13

; Animation table for portrait B
C30C2F:  dw C30C32       ; Show portrait
         db $FE          ; Freeze

; OAM for portrait B
C30C32:  db $0D          ; Tiles: 13
         dw $0080,$2280  ; Tile 1
         dw $0090,$2282  ; Tile 2
         dw $1080,$2284  ; Tile 3
         dw $1090,$2286  ; Tile 4
         dw $0020,$2288  ; Tile 5
         dw $0820,$2289  ; Tile 6
         dw $1020,$228A  ; Tile 7
         dw $1820,$228B  ; Tile 8
         dw $2020,$228C  ; Tile 9
         dw $2000,$228D  ; Tile 10
         dw $2008,$228E  ; Tile 11
         dw $2010,$228F  ; Tile 12
         dw $2018,$2298  ; Tile 13

; Animation table for portrait C
C30C67:  dw C30C6A       ; Show portrait
         db $FE          ; Freeze

; OAM for portrait C
C30C6A:  db $0D          ; Tiles: 13
         dw $0080,$24A0  ; Tile 1
         dw $0090,$24A2  ; Tile 2
         dw $1080,$24A4  ; Tile 3
         dw $1090,$24A6  ; Tile 4
         dw $0020,$24A8  ; Tile 5
         dw $0820,$24A9  ; Tile 6
         dw $1020,$24AA  ; Tile 7
         dw $1820,$24AB  ; Tile 8
         dw $2020,$24AC  ; Tile 9
         dw $2000,$24AD  ; Tile 10
         dw $2008,$24AE  ; Tile 11
         dw $2010,$24AF  ; Tile 12
         dw $2018,$24B8  ; Tile 13

; Animation table for portrait D
C30C9F:  dw C30CA2       ; Show portrait
         db $FE          ; Freeze

; OAM for portrait D
C30CA2:  db $0D          ; Tiles: 13
         dw $0080,$26C0  ; Tile 1
         dw $0090,$26C2  ; Tile 2
         dw $1080,$26C4  ; Tile 3
         dw $1090,$26C6  ; Tile 4
         dw $0020,$26C8  ; Tile 5
         dw $0820,$26C9  ; Tile 6
         dw $1020,$26CA  ; Tile 7
         dw $1820,$26CB  ; Tile 8
         dw $2020,$26CC  ; Tile 9
         dw $2000,$26CD  ; Tile 10
         dw $2008,$26CE  ; Tile 11
         dw $2010,$26CF  ; Tile 12
         dw $2018,$26D8  ; Tile 13

; Draw member's level, HP, and MP
C30CD7:  STX $EF         ; Pos tbl ptr LBs
         LDA #$C3        ; Bank: C3
         STA $F1         ; Set ptr HB
         LDX $67         ; Actor address
         LDA $0008,X     ; Level
         JSR C30563      ; Turn into text
         REP #$20        ; 16-bit A
         LDA [$EF]       ; Tilemap ptr
         TAX             ; Move it to X
         SEP #$20        ; 8-bit A
         JSR C30539      ; Draw level
         LDX $67         ; Actor address
         LDA $000B,X     ; Max HP LB
         STA $F3         ; Memorize it
         LDA $000C,X     ; Max HP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30DFD      ; Cap at 9999
         JSR C305B1      ; Turn into text
         LDY #$0004      ; Map ptr index
         JSR C30D8C      ; Draw max HP
         LDY $67         ; Actor address
         JSR C32C35      ; Truncate HP
         LDA $0009,Y     ; HP LB
         STA $F3         ; Memorize it
         LDA $000A,Y     ; HP HB
         STA $F4         ; Memorize it
         JSR C305B1      ; Turn into text
         LDY #$0002      ; Map ptr index
         JSR C30D8C      ; Draw HP
         JSR C30D96      ; Can use magic?
         BCC C30D5A      ; Hide MP if not
         LDX $67         ; Actor address
         LDA $000F,X     ; Max MP LB
         STA $F3         ; Memorize it
         LDA $0010,X     ; Max MP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30E0A      ; Cap at 999
         JSR C305B1      ; Turn into text
         LDY #$0008      ; Map ptr index
         JSR C30D8C      ; Draw max MP
         LDY $67         ; Actor address
         JSR C32C57      ; Truncate MP
         LDA $000D,Y     ; MP LB
         STA $F3         ; Memorize it
         LDA $000E,Y     ; MP HB
         STA $F4         ; Memorize it
         JSR C305B1      ; Turn into text
         LDY #$0006      ; Map ptr index
         JMP C30D8C      ; Draw MP

; Fork: Hide MP
C30D5A:  LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         REP #$20        ; 16-bit A
         LDY #$0006      ; Point to MP ptr
         LDA [$EF],Y     ; Tilemap ptr
         SEC             ; Prepare SBC
         SBC #$0006      ; Point to "MP"
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX #$000C      ; Letters: 12
         LDA #$FF        ; Space char
C30D76:  STA $2180       ; Add to string
         DEX             ; One less left
         BNE C30D76      ; Loop till last
         STZ $2180       ; End string
         LDY #$9E89      ; 7E/9E89
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw 12 spaces
         RTS

; Draw member's current or max HP or MP
C30D8C:  REP #$20        ; 16-bit A
         LDA [$EF],Y     ; Tilemap ptr
         TAX             ; Move it to X
         SEP #$20        ; 8-bit A
         JMP C30513      ; Draw 4 digits

; Determine whether actor can use magic
C30D96:  LDA $1A69       ; Espers LB
         ORA $1A6A       ; Add byte 2
         ORA $1A6B       ; Add byte 3
         ORA $1A6C       ; Add byte 4
         BNE C30DCE      ; OK if got any
         LDX $67         ; Actor's address
         TDC             ; Clear A
         LDA $0000,X     ; Actor
         CMP #$0C        ; Gogo?
         BEQ C30DCE      ; Allow if so
         BCS C30DCC      ; Deny Umaro/guest
         STA $4202       ; Set multiplicand
         LDA #$36        ; Spell list length
         STA $4203       ; Set multiplier
         NOP
         NOP
         NOP
         LDY #$0036      ; Spells left: 54
         LDX $4216       ; Index product
C30DC1:  LDA $1A6E,X     ; Spell mastery
         CMP #$FF        ; Fully learned?
         BEQ C30DCE      ; Allow if so
         INX             ; Point to next
         DEY             ; One less left
         BNE C30DC1      ; Loop till last
C30DCC:  CLC             ; Access: No
         RTS             ; Exit
C30DCE:  SEC             ; Access: Yes
         RTS

; Determine max HP or MP with gear bonus
C30DD0:  REP #$20        ; 16-bit A
         LDA $F3         ; Max HP or MP
         AND #$3FFF      ; Clear flags
         STA $E7         ; Memorize value
         LDA $F3         ; Max HP or MP
         AND #$C000      ; Get bonus flags
         CLC             ; Prepare ROL
         ROL A           ; Put in b7 & C
         ROL A           ; Put in C & b0
         ROL A           ; Put in b0-b1
         ROL A           ; Put in b1-b2
         TAX             ; Index them
         LDA $E7         ; Max HP or MP
         JMP (C30DE9,X)  ; Apply bonus

; Jump table for the above
C30DE9:  dw C30DF1       ; No bonus
         dw C30DF3       ; HP or MP + 25%
         dw C30DF4       ; HP or MP + 50%
         dw C30DF2       ; HP or MP + 12.5%

; Boost max HP or MP based on entry point
C30DF1:  TDC             ; Clear bonus
C30DF2:  LSR A           ; Halve bonus
C30DF3:  LSR A           ; Halve bonus
C30DF4:  LSR A           ; Halve bonus
         CLC             ; Prepare ADC
         ADC $E7         ; Add max value
         STA $F3         ; Memorize sum
         SEP #$20        ; 8-bit A
         RTS

; Enforce HP cap
C30DFD:  LDX $F3         ; Max HP
         CPX #$2710      ; Under 10000?
         BCC C30E09      ; Exit if so
         LDX #$270F      ; Enforce 9999
         STX $F3         ; Save changes
C30E09:  RTS

; Enforce MP cap
C30E0A:  LDX $F3         ; Max MP
         CPX #$03E8      ; Under 1000?
         BCC C30E16      ; Exit if so
         LDX #$03E7      ; Enforce 999
         STX $F3         ; Save changes
C30E16:  RTS

; Restore cursor position in inventory
C30E17:  LDY $022F       ; Old list pos
         STY $4F         ; Set as current
         LDA $4F         ; List column
         STA $4D         ; Set as onscreen
         LDA $0231       ; Old scroll pos
         BRA C30E89      ; Restore it, etc.

; Interchange cursor memory for swapped members
C30E25:  TDC             ; Clear A
         LDA $4B         ; Chosen slot B
         ASL A           ; Double it
         TAX             ; Index it
         LDA $28         ; Chosen slot A
         ASL A           ; Double it
         TAY             ; Index it
         REP #$20        ; 16-bit A
         LDA $0236,X     ; B's Skills pos
         STA $E7         ; Memorize it
         LDA $0236,Y     ; A's Skills pos
         STA $0236,X     ; Set as B's
         LDA $E7         ; B's Skills pos
         STA $0236,Y     ; Set as A's
         LDA $023E,X     ; B's Magic pos
         STA $E7         ; Memorize it
         LDA $023E,Y     ; A's Magic pos
         STA $023E,X     ; Set as B's
         LDA $E7         ; B's Magic pos
         STA $023E,Y     ; Set as A's
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $4B         ; Chosen slot B
         TAX             ; Index it
         LDA $28         ; Chosen slot A
         TAY             ; Index it
         LDA $0246,X     ; B's Magic bar
         STA $E0         ; Memorize pos
         LDA $0246,Y     ; A's Magic bar
         STA $0246,X     ; Set as B's
         LDA $E0         ; B's Magic bar
         STA $0246,Y     ; Set as A's
         RTS

; Restore cursor position in Skills menu
C30E6A:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $0236,X     ; Former position
         STY $4D         ; Set as current
         RTS

; Restore cursor position in Magic menu
C30E75:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $023E,X     ; Old list pos
         STY $4F         ; Set as current
         LDA $4F         ; List column
         STA $4D         ; Set as onscreen
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $0246,X     ; Old scroll pos
C30E89:  STA $4A         ; Set as current
         LDA $50         ; List row
         SEC             ; Prepare SBC
         SBC $4A         ; Sub scroll pos
         STA $4E         ; Set onscreen row
         RTS

; Upload BG1 tilemaps A and B
C30E93:  LDY #$0000      ; $0000
         STY $2116       ; Set VRAM ptr
         LDY #$3849      ; 7E/3849
         STY $4302       ; Set src LBs
         BRA C30EF3      ; Move data

; Upload BG1 tilemaps B and C
C30EA1:  LDY #$0400      ; $0400
         STY $2116       ; Set VRAM ptr
         LDY #$4049      ; 7E/4049
         STY $4302       ; Set src LBs
         BRA C30EF3      ; Move data

; Upload BG1 tilemaps C and D
C30EAF:  LDY #$0800      ; $0800
         STY $2116       ; Set VRAM ptr
         LDY #$4849      ; 7E/4849
         STY $4302       ; Set src LBs
         BRA C30EF3      ; Move data

; Upload BG2 tilemaps A and B
C30EBD:  LDY #$1000      ; $1000
         STY $2116       ; Set VRAM ptr
         LDY #$5849      ; 7E/5849
         STY $4302       ; Set src LBs
         BRA C30EF3      ; Move data

; Upload BG2 tilemaps C and D
C30ECB:  LDY #$1800      ; $1800
         STY $2116       ; Set VRAM ptr
         LDY #$6849      ; 7E/6849
         STY $4302       ; Set src LBs
         BRA C30EF3      ; Move data

; Upload BG3 tilemaps A and B
C30ED9:  LDY #$4000      ; $4000
         STY $2116       ; Set VRAM ptr
         LDY #$7849      ; 7E/7849
         STY $4302       ; Set src LBs
         BRA C30EF3      ; Move data

; Upload BG3 tilemaps C and D
C30EE7:  LDY #$4800      ; $4800
         STY $2116       ; Set VRAM ptr
         LDY #$8849      ; 7E/8849
         STY $4302       ; Set src LBs
C30EF3:  LDA #$01        ; 2Rx1B to PPU
         STA $4300       ; Set DMA mode
         LDA #$18        ; $2118
         STA $4301       ; To VRAM
         LDA #$7E        ; Bank: 7E
         STA $4304       ; Set src HB
         LDY #$1000      ; Bytes: 4096
         STY $4305       ; Set data size
         LDA #$01        ; Channel: 0
         STA $420B       ; Move data
         RTS

; Play cursor sound
C30F0E:  LDA $AE         ; Started sound
         CMP #$21        ; Cursor's?
         BEQ C30F1C      ; Exit if so
C30F14:  LDA #$21        ; APU command
         STA $AE         ; Prevent repeat
         STA $002140     ; Set I/O port 0
C30F1C:  RTS

; Play click sound
C30F1D:  LDA #$20        ; APU command
         STA $002140     ; Set I/O port 0
         RTS

; Play save sound
C30F24:  LDA #$23        ; APU command
         STA $002140     ; Set I/O port 0
         RTS

; Play buzzer sound
C30F2B:  LDA #$22        ; APU command
         STA $002140     ; Set I/O port 0
         RTS

; Play letter deletion sound
C30F32:  LDA #$24        ; APU command
         STA $002140     ; Set I/O port 0
         RTS

; Play cash register sound
C30F39:  LDA #$BF        ; Sound number
C30F3B:  STA $001301     ; Set I/O port 1
         LDA #$18        ; APU command
         STA $001300     ; Set I/O port 0
         LDA #$80        ; Volume specs
         STA $001302     ; Set I/O port 2
         JSL $C50004     ; Update ports
         RTS

; Play recovery sound
C30F50:  LDA #$C5        ; Sound number
         BRA C30F3B      ; Set vol, etc.

; Set to upload BG1 tilemaps A and B
C30F54:  LDY #$0000      ; $0000
         STY $14         ; Set VRAM ptr
         LDY #$3849      ; 7E/3849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$1000      ; Bytes: 4096
         STY $12         ; Set data size
         RTS

; Set to upload BG1 tilemap A
C30F68:  LDY #$0000      ; $0000
         STY $14         ; Set VRAM ptr
         LDY #$3849      ; 7E/3849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $12         ; Set data size
         RTS

; Set to upload BG1 tilemap B
C30F7C:  LDY #$0400      ; $0400
         STY $14         ; Set VRAM ptr
         LDY #$4049      ; 7E/4049
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $12         ; Set data size
         RTS

; Set to upload BG3 tilemaps A and B
C30F90:  LDY #$4000      ; $4000
         STY $14         ; Set VRAM ptr
         LDY #$7849      ; 7E/7849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$1000      ; Bytes: 4096
         STY $12         ; Set data size
         RTS

; Set to upload BG3 tilemap A (version 1)
C30FA4:  LDY #$4000      ; $4000
         STY $14         ; Set VRAM ptr
         LDY #$7849      ; 7E/7849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $12         ; Set data size
         RTS

; Set to upload BG3 tilemap B (version 1)
C30FB8:  LDY #$4400      ; $4400
         STY $14         ; Set VRAM ptr
         LDY #$8049      ; 7E/8049
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $12         ; Set data size
         RTS

; Set to upload BG3 tilemap A (version 2)
C30FCC:  LDY #$4000      ; $4000
         STY $1B         ; Set VRAM ptr
         LDY #$7849      ; 7E/7849
         STY $1D         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $19         ; Set data size
         RTS

; Set to upload BG3 tilemap B (version 2)
C30FE0:  LDY #$4400      ; $4400
         STY $1B         ; Set VRAM ptr
         LDY #$8049      ; 7E/8049
         STY $1D         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $19         ; Set data size
         RTS

; Disable conditional upload during NMI
C30FF4:  STZ $1B         ; Null dst LB
         STZ $1C         ; Null dst HB
         RTS

; Load specified palette (for ending)
C30FF9:  STA $ED         ; Set src HB
         STY $E7         ; Set dst LBs
         STX $EB         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set dst HB
         LDY $00         ; Index: 0
         REP #$20        ; 16-bit A
C31007:  LDA [$EB],Y     ; Load color
         STA [$E7],Y     ; Save in RAM
         INY             ; Index +1
         INY             ; Index +1
         CPY #$0020      ; Copied 16?
         BNE C31007      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Set to gradually convert one palette into another
C31015:  PHA             ; Save slowness
         STY $E7         ; Save dst LBs
         STX $EB         ; Save src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Save dst HB
         LDA #$00        ; Min slot: 0
         LDY #C31048     ; C3/1048
         JSR C311DE      ; Queue fade fn
         PLA             ; Fade slowness
         STA $7E37CA,X   ; Put in queue
         LDA $E9         ; Dest HB
         STA $7E36C9,X   ; Put in queue
         LDA $ED         ; Source HB
         STA $7E36CA,X   ; Put in queue
         REP #$20        ; 16-bit A
         LDA $E7         ; Dest LBs
         STA $7E33C9,X   ; Put in queue
         LDA $EB         ; Source LBs
         STA $7E3449,X   ; Put in queue
         SEP #$20        ; 8-bit A
         RTS

; Gradually convert one palette into another
C31048:  TAX             ; Index mode
         JMP (C3104C,X)  ; Handle mode

; Jump table for the above
C3104C:  dw C31050       ; Initialize timer
         dw C31061       ; Modify palette

; Mode 0: Initialize timer
C31050:  LDX $2D         ; Queue index
         LDA #$1F        ; Frames: 31
         STA $3349,X     ; Set fade timer
         LDA $00         ; Clear A
         STA $334A,X     ; Timer HB: 0
         INC $3649,X     ; Mode +1
         SEC             ; Set to requeue
         RTS

; Mode 1: Modify palette
C31061:  LDX $2D         ; Queue index
         LDA $35C9,X     ; Delay over?
         BNE C3109D      ; Exit if not
         LDA $37CA,X     ; Slowness
         STA $35C9,X     ; Set delay
         LDA $36C9,X     ; Dest HB
         STA $E2         ; Memorize it
         LDA $36CA,X     ; Source HB
         STA $E5         ; Memorize it
         REP #$20        ; 16-bit A
         LDA $33C9,X     ; Dest LBs
         STA $E0         ; Memorize them
         LDA $3449,X     ; Source LBs
         STA $E3         ; Memorize them
         LDA $3349,X     ; Fade timer
         STA $F1         ; Memorize it
         JSR C310A2      ; Alter palette
         SEP #$20        ; 8-bit A
         LDX $002D       ; Queue index
         LDA $3349,X     ; Timer expired?
         BEQ C3109B      ; Dequeue if so
         DEC $3349,X     ; Fade timer -1
         BNE C3109D      ; Branch if > 0
C3109B:  CLC             ; Set to dequeue
         RTS             ; Exit
C3109D:  DEC $35C9,X     ; Fade delay -1
         SEC             ; Set to requeue
         RTS

; Partially convert one palette into another
C310A2:  LDX #$0010      ; Colors: 16
         LDY $00         ; Color index: 0
C310A7:  LDA [$E0],Y     ; Actual color
         STA $E7         ; Memorize it
         LDA [$E3],Y     ; Target color
         STA $E9         ; Memorize it
         JSR C310BC      ; Alter color
         LDA $E7         ; ...
         STA [$E0],Y     ; Save changes
         INY             ; Color index +1
         INY             ; Color index +1
         DEX             ; One less color
         BNE C310A7      ; Loop till last
         RTS

; Partially convert one color into another
C310BC:  LDA $E7         ; Actual color
         AND #$001F      ; Get red
         STA $EB         ; Memorize it
         LDA $E9         ; Target color
         AND #$001F      ; Get red
         SEC             ; Prepare SBC
         SBC $EB         ; Both match?
         BEQ C310D9      ; Skip if so
         BCC C310D7      ; -1 if lesser
         CMP $F1         ; Diff < timer?
         BCC C310D9      ; Skip if so
         INC $EB         ; Red +1
         BRA C310D9      ; Skip a line
C310D7:  DEC $EB         ; Red -1

; Fork: Handle green
C310D9:  LDA $E7         ; Actual color
         AND #$03E0      ; Get green
         STA $ED         ; Memorize it
         LDA $E9         ; Target color
         AND #$03E0      ; Get green
         SEC             ; Prepare SBC
         SBC $ED         ; Both match?
         BEQ C31106      ; Skip if so
         BCC C310FE      ; -1 if lesser
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         XBA             ; Now 0-31
         CMP $F1         ; Diff < timer?
         BCC C31106      ; Skip if so
         CLC             ; Prepare ADC
         LDA $ED         ; Actual green
         ADC #$0020      ; Green +1
         STA $ED         ; Save changes
         BRA C31106      ; Do blue
C310FE:  LDA $ED         ; Actual green
         SEC             ; Prepare SBC
         SBC #$0020      ; Green -1
         STA $ED         ; Save changes

; Fork: Handle blue
C31106:  LDA $E7         ; Actual color
         AND #$7C00      ; Get blue
         STA $EF         ; Memorize it
         LDA $E9         ; Target color
         AND #$7C00      ; Get blue
         SEC             ; Prepare SBC
         SBC $EF         ; Both match?
         BEQ C31136      ; Skip if so
         BCC C3112E      ; -1 if lesser
         SEP #$20        ; 8-bit A
         XBA             ; ÷256
         LSR A           ; ÷512
         LSR A           ; Now 0-31
         REP #$20        ; 16-bit A
         CMP $F1         ; Diff < timer?
         BCC C31136      ; Skip if so
         CLC             ; Prepare ADC
         LDA $EF         ; Actual blue
         ADC #$0400      ; Blue +1
         STA $EF         ; Save changes
         BRA C31136      ; Merge RGB
C3112E:  LDA $EF         ; Actual blue
         SEC             ; Prepare SBC
         SBC #$0400      ; Blue -1
         STA $EF         ; Save changes

; Fork: Merge RGB components
C31136:  LDA $EB         ; Altered red
         ORA $ED         ; Add green
         ORA $EF         ; Add blue
         STA $E7         ; Uh...
         RTS

; White palette for an ending transition
C3113F:  dw $0000,$7FFF,$7FFF,$7FFF,$7FFF,$7FFF,$7FFF,$7FFF
         dw $7FFF,$7FFF,$7FFF,$7FFF,$7FFF,$7FFF,$7FFF,$7FFF

; Black palette for most ending transitions
C3115F:  dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
         dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000

; Reset OAM and animation queue
C3117F:  LDX $00         ; Clear X
         STX $2D         ; Queue index: 0
         STX $2F         ; No use...
         REP #$20        ; 16-bit A
         JSR C311B9      ; Reset OAM
         SEP #$10        ; 8-bit X, Y
         LDX #$7E        ; Bank: 7E
         PHX             ; Put on stack
         PLB             ; Set DB to 7E
         LDX #$00        ; Queue slot: 1
C31192:  STZ $3249,X     ; Anim fn: None
         STZ $3649,X     ; Anim mode: 0
         STZ $35C9,X     ; Misc. specs: 0
         STZ $3749,X     ; OAM complements
         STZ $33C9,X     ; Fractional X: 0
         STZ $3449,X     ; Fractional Y: 0
         STZ $34C9,X     ; H-Speed: 0
         STZ $3549,X     ; V-Speed: 0
         INX             ; Index +1
         INX             ; Index +1
         CPX #$80        ; Done 64 slots?
         BNE C31192      ; Loop if not
         LDX #$00        ; Bank: 00
         PHX             ; Put on stack
         PLB             ; Set DB to 0
         SEP #$20        ; 8-bit A
         REP #$10        ; 16-bit X, Y
         RTS

; Reset OAM
C311B9:  LDX $00         ; Index: 0
C311BB:  LDA #$E001      ; X=1, Y=224
         STA $0300,X     ; Put offscreen
         INX             ; Index +1
         INX             ; Index +1
         LDA #$0001      ; Tile num: 1
         STA $0300,X     ; Set attribs
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0200      ; Past Lo-OAM?
         BNE C311BB      ; Loop if not
         LDY $00         ; Index: 0
         TYA             ; Clear A
C311D3:  STA $0500,Y     ; Clear Hi-OAM
         INY             ; Index +1
         INY             ; Index +1
         CPY #$0020      ; Past Hi-OAM?
         BNE C311D3      ; Loop if not
         RTS

; Queue animation function, include queue index
C311DE:  TAX             ; Starting slot
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TXA             ; Starting slot
         JSR C311F6      ; Queue anim fn
         SEP #$20        ; 8-bit A
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDA $2D         ; Caller's index
         STA $7E374A,X   ; Put in queue
         INC $2F         ; No use...
         RTS

; Queue animation function
C311F6:  XBA             ; Switch to HB
         LDA #$00        ; Clear it
         XBA             ; Starting slot
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         REP #$20        ; 16-bit A
         TAX             ; Index it
C31201:  LDA $3249,X     ; Empty slot?
         BNE C3120B      ; Skip if not
         TYA             ; Animation fn
         STA $3249,X     ; Put in queue
         RTS

; Fork: Try next slot
C3120B:  INX             ; Index +1
         INX             ; Index +1
         CPX #$0080      ; Past slot 64?
         BNE C31201      ; Loop if not
         DEX             ; Index -1
         DEX             ; Index -1
         TYA             ; Animation fn
         STA $3249,X     ; Put in queue
C31218:  BRA C31218      ; Freeze game...
         RTS             ; ...

; Process animation queue, hide inactive objects
C3121B:  PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDX #$0300      ; 7E/0300
         STX $0E         ; Set Lo-OAM ptr
         LDX #$0500      ; 7E/0500
         STX $10         ; Set Hi-OAM ptr
         LDA #$03        ; Tile: 1 of 4
         STA $33         ; Set Hi-OAM index
         STZ $34         ; Hi-OAM: 4x 8x8
         LDX #$0080      ; Objects: 128
         STX $31         ; Set space left
         LDX $00         ; Queue index: 0
         REP #$20        ; 16-bit A
C31239:  LDA $3249,X     ; Animation fn
         BEQ C31260      ; Skip if blank
         STX $2D         ; Set queue index
         PHX             ; Save index
         STA $2B         ; Set anim fn
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $3649,X     ; Anim mode
         ASL A           ; Double it
         JSR C3126E      ; Run anim fn
         REP #$20        ; 16-bit A
         PLX             ; Queue index
         BCS C31260      ; Branch if kept
         STZ $3249,X     ; Anim fn: None
         STZ $3649,X     ; Anim mode: 0
         STZ $35C9,X     ; Misc. specs: 0
         STZ $3749,X     ; OAM complements
         DEC $2F         ; No use...
C31260:  INX             ; Index +1
         INX             ; Index +1
         CPX #$0080      ; Done 64 slots?
         BNE C31239      ; Loop if not
         JSR C313A3      ; Purge OAM
         SEP #$20        ; 8-bit A
         PLB             ; Restore DB
         RTS

; Execute queued animation function
C3126E:  JMP ($002B)     ; Run anim fn

; Initialize M7 or object's pose number and timer
C31271:  TDC             ; Clear A
         STA $36C9,X     ; Pose: 1st
         REP #$20        ; 16-bit A
         LDA $32C9,X     ; Anim ptr LBs
         STA $EB         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA $35CA,X     ; Anim ptr HB
         STA $ED         ; Set src HB
         LDY #$0002      ; Skip pose ptr
         LDA [$EB],Y     ; Pose timer
         STA $36CA,X     ; Set sprite's
         RTS

; Handle object's pose timer, then define OAM
C3128C:  JSR C31292      ; Pose timer -1
         JMP C312DE      ; Define OAM

; Handle pose or Mode 7 timer
C31292:  LDX $2D         ; Queue index
         LDY $00         ; ...
         REP #$20        ; 16-bit A
         LDA $32C9,X     ; Anim ptr LBs
         STA $EB         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA $35CA,X     ; Anim ptr HB
         STA $ED         ; Set src HB

; Fork: Handle control codes
C312A4:  LDA $36CA,X     ; Pose timer
         CMP #$FE        ; Infinite?
         BEQ C312CD      ; Exit if so
         CMP #$FF        ; Loop point?
         BNE C312B7      ; Branch if not
         STZ $36C9,X     ; Pose: 1st
         JSR C312CE      ; Set new timer
         BRA C312A4      ; Repeat checks

; Fork: Check if expired
C312B7:  LDA $36CA,X     ; Timer expired?
         BNE C312CA      ; Branch if not
         LDA $36C9,X     ; Pose index
         CLC             ; ...
         ADC #$03        ; Point to next
         STA $36C9,X     ; Save changes
         JSR C312CE      ; Set new timer
         BRA C312A4      ; Repeat checks

; Fork: Decrease timer
C312CA:  DEC $36CA,X     ; Timer -1
C312CD:  RTS

; Initialize pose or Mode 7 timer
C312CE:  SEP #$10        ; 8-bit X, Y
         LDA $36C9,X     ; Pose index
         TAY             ; Index it
         INY             ; Skip ptr LB
         INY             ; Skip ptr HB
         LDA [$EB],Y     ; Pose timer
         STA $36CA,X     ; Set object's
         REP #$10        ; 16-bit X, Y
         RTS

; Define OAM for object's tiles
C312DE:  SEP #$10        ; 8-bit X, Y
         LDA $36C9,X     ; Pose index
         TAY             ; Index it
         REP #$20        ; 16-bit A
         LDA [$EB],Y     ; Pose OAM ptr
         STA $E7         ; Set src LBs
         INY             ; ...
         INY             ; ...
         SEP #$20        ; 8-bit A
         LDA $35CA,X     ; OAM ptr HB
         STA $E9         ; Set src HB
         REP #$10        ; 16-bit X, Y
         LDY $00         ; Index: 0
         LDA $31         ; OAM's full?
         BEQ C31366      ; Exit if so
         LDA [$E7],Y     ; Tile count
         STA $E6         ; Memorize it
         BEQ C31366      ; Exit if none
         INY             ; Index +1

; Fork: Large tile (16x16)
C31302:  LDA [$E7],Y     ; Tile X & flag
         STA $E0         ; Memorize them
         BPL C3131B      ; Branch if 8x8
         TDC             ; Clear A
         LDA $33         ; Hi-OAM index
         TAX             ; Index it
         LDA.L C3139F,X  ; Size flag
         CLC             ; Prepare ADC
         ADC $34         ; Add flag pack
         STA $34         ; Set flag pack
         STA ($10)       ; Put in Hi-OAM
         LDX $2D         ; Queue index
         BRA C3131F      ; Skip 2 lines

; Fork: Small tile (8x8)
C3131B:  LDA $34         ; OAM flag pack
         STA ($10)       ; Put in Hi-OAM
C3131F:  LDA $E0         ; Tile's X-Pos
         AND #$7F        ; Clear flag
         STA $E0         ; Save changes

; Fork: Pan with BG1
C31325:  LDA $364A,X     ; Sprite flags
         BIT #$01        ; Pan with BG1?
         BEQ C31339      ; Branch if not
         STZ $E1         ; Tile's X HB: 0
         REP #$20        ; 16-bit A
         LDA $E0         ; Tile's rel X
         SEC             ; Prepare SBC
         SBC $35         ; Deduct BG1 X-Pos
         STA $E0         ; Save changes
         SEP #$20        ; 8-bit A

; Fork: Define Lo-OAM, do next tile
C31339:  JSR C31367      ; Adjust attribs
         DEC $33         ; Hi-OAM index -1
         BPL C3134A      ; Branch if 0+
         LDA #$03        ; Tile: 1 of 4
         STA $33         ; Reset size index
         STZ $34         ; Hi-OAM: 4x 8x8
         REP #$20        ; 16-bit A
         INC $10         ; Hi-OAM ptr +1
C3134A:  REP #$20        ; 16-bit A
         LDA $E0         ; Tile coords
         STA ($0E)       ; Save in OAM
         INC $0E         ; Lo-OAM ptr +1
         INC $0E         ; Lo-OAM ptr +1
         LDA $E2         ; Tile num/attr
         STA ($0E)       ; Save in OAM
         INC $0E         ; Lo-OAM ptr +1
         INC $0E         ; Lo-OAM ptr +1
         SEP #$20        ; 8-bit A
         DEC $31         ; Space left -1
         BEQ C31366      ; Exit if full
         DEC $E6         ; Tiles left -1
         BNE C31302      ; Loop till last
C31366:  RTS

; Determine object tile's coordinates, load attributes
C31367:  LDA $E0         ; Tile's rel X
         CLC             ; Prepare ADC
         ADC $33CA,X     ; Add object's X
         STA $E0         ; Save changes
         INY             ; Index +1
         LDA [$E7],Y     ; Tile's rel Y
         CLC             ; Prepare ADC
         ADC $344A,X     ; Add object's Y
         STA $E1         ; Memorize sum
         INY             ; Index +1
         LDA [$E7],Y     ; Tile num LSBs
         STA $E2         ; Memorize them
         INY             ; Index +1
         LDA $364A,X     ; Sprite flags
         BIT #$02        ; Mirror H-wise?
         BEQ C3138B      ; Branch if not
         LDA [$E7],Y     ; Tile attributes
         ORA #$40        ; Add H-Flip
         BRA C3138D      ; Skip a line
C3138B:  LDA [$E7],Y     ; Tile attributes
C3138D:  STA $E3         ; Memorize them
         LDA $3749,X     ; OAM complements
         BEQ C3139D      ; Exit if none
         LDA $E3         ; Tile attributes
         AND #$F1        ; Clear palette
         ORA $3749,X     ; Add complements
         STA $E3         ; Save changes
C3139D:  INY             ; Index +1
         RTS

; Hi-OAM complements
C3139F:  db $80          ; Tile 4: Large
         db $20          ; Tile 3: Large
         db $08          ; Tile 2: Large
         db $02          ; Tile 1: Large

; Hide inactive tiles in OAM
C313A3:  LDY $31         ; Unused tiles
         BEQ C313B7      ; Exit if none
         LDX #$01FC      ; Tile: Last
         LDA #$E001      ; X=1, Y=224
C313AD:  STA $0300,X     ; Set position
         DEX             ; OAM index -1
         DEX             ; OAM index -1
         DEX             ; OAM index -1
         DEX             ; OAM index -1
         DEY             ; Tiles left -1
         BNE C313AD      ; Loop till last
C313B7:  RTS

; Trigger NMI, decode joypads, etc.
C313B8:  JSR C313D3      ; Trigger NMI
         LDA $46         ; Menu flags
         BIT #$20        ; Scroll list?
         BEQ C313C4      ; Branch if not
         JSR C38886      ; Scroll BG1
C313C4:  JSL C3AC99      ; Decode joypads
         LDA $20         ; Transition timer
         BEQ C313D2      ; Exit if off
         TDC             ; Clear A
         TAY             ; Clear Y
         STY $08         ; No-autofire keys
         STY $0A         ; Semi-auto keys
C313D2:  RTS

; Trigger NMI, allow cursor sound to repeat
C313D3:  LDA #$81        ; Stop IRQ timers
         STA $4200       ; On: NMI, joypads
         STA $24         ; Mark NMI request
         CLI             ; Unmask IRQs
C313DB:  LDA $24         ; Back from NMI?
         BNE C313DB      ; Loop if not
         SEI             ; Mask IRQs
         LDA $44         ; Brightness
         STA $2100       ; Apply it now
         LDA $43         ; Queued HDMA
         STA $420C       ; Update channels
         LDA $B5         ; Mosaic settings
         STA $2106       ; Apply to screen
         STZ $AE         ; Allow SFX repeat
         RTS

; Handle NMI (menu, ending)
C313F2:  PHP             ; ...
         REP #$30        ; 16-bit A, X, Y
         PHA             ; Save A
         PHX             ; Save X
         PHY             ; Save Y
         PHB             ; Save DB
         PHD             ; Save DP
         SEP #$20        ; 8-bit A
         LDA $4210       ; Clear NMI flag
         LDA #$00        ; Clear A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDX #$0000      ; Clear X
         PHX             ; Put on stack
         PLD             ; Set DP to 0
         LDA $24         ; Manual NMI?
         BEQ C3141C      ; Branch if not
         JSR C3147D      ; Refresh screen
         REP #$20        ; 16-bit A
         INC $CF         ; Ending timer +1
         SEP #$20        ; 8-bit A
         LDY $20         ; Transition timer
         BEQ C3141C      ; Ignore if off
         DEY             ; Timer -1
         STY $20         ; Save changes
C3141C:  JSL $C00015     ; Event timers -1
         JSL C31433      ; Play time +1
         INC $23         ; NMI count +1
         TDC             ; Clear A
         STA $24         ; Unmark manual NMI
         REP #$30        ; 16-bit A, X, Y
         PLD             ; Restore DP
         PLB             ; Restore DB
         PLY             ; Restore Y
         PLX             ; Restore X
         PLA             ; Restore A
         PLP             ; ...
         RTI

; Handle IRQ...
C31432:  RTI

; Advance play time (NMI)
C31433:  LDA $021E       ; Frames
         CMP #$3C        ; 60?
         BEQ C3143C      ; +1 sec if so
         BRA C31467      ; +1 frame

; Fork: Seconds +1
C3143C:  STZ $021E       ; Frames = 0
         LDA $021D       ; Seconds
         CMP #$3B        ; 59?
         BEQ C3144B      ; +1 min if so
         INC $021D       ; +1 second
         BRA C31467      ; +1 frame

; Fork: Minutes +1
C3144B:  STZ $021D       ; Seconds = 0
         LDA $021C       ; Minutes
         CMP #$3B        ; 59?
         BEQ C3145A      ; +1 hour if so
         INC $021C       ; +1 minute
         BRA C31467      ; +1 frame

; Fork: Hours +1
C3145A:  STZ $021C       ; Minutes = 0
         LDA $021B       ; Hours
         CMP #$63        ; 99?
         BEQ C31467      ; Branch if so
         INC $021B       ; +1 hour

; Fork: Frames +1
C31467:  LDA $021B       ; Hours
         CMP #$63        ; 99?
         BNE C31478      ; Branch if not
         LDA $021C       ; Minutes
         CMP #$3B        ; 59?
         BNE C31478      ; Branch if not
         STZ $021D       ; Seconds = 0
C31478:  INC $021E       ; +1 frame
         TDC             ; Clear A
         RTL

; Refresh screen (NMI)
C3147D:  STZ $420C       ; Disable HDMA
         STZ $420B       ; Disable DMA...
         LDA $35         ; BG1 X-Pos LB
         STA $210D       ; Apply it now
         LDA $36         ; BG1 X-Pos HB
         STA $210D       ; Apply it now
         LDA $37         ; BG1 Y-Pos LB
         STA $210E       ; Apply it now
         LDA $38         ; BG1 Y-Pos HB
         STA $210E       ; Apply it now
         LDA $39         ; BG2 X-Pos LB
         STA $210F       ; Apply it now
         LDA $3A         ; BG2 X-Pos HB
         STA $210F       ; Apply it now
         LDA $3B         ; BG2 Y-Pos LB
         STA $2110       ; Apply it now
         LDA $3C         ; BG2 Y-Pos HB
         STA $2110       ; Apply it now
         LDA $3D         ; BG3 X-Pos LB
         STA $2111       ; Apply it now
         LDA $3E         ; BG3 X-Pos HB
         STA $2111       ; Apply it now
         LDA $3F         ; BG3 Y-Pos LB
         STA $2112       ; Apply it now
         LDA $40         ; BG3 Y-Pos HB
         STA $2112       ; Apply it now
         JSR C3E1E7      ; Refresh Mode 7
         JSR C314CE      ; Refresh OAM
         JSR C3153D      ; Refresh CGRAM
         JSR C314F3      ; Do VRAM DMA A
         JMP C31517      ; Do VRAM DMA B

; Refresh OAM (NMI)
C314CE:  LDX $00         ; $0000
         STX $2102       ; Set OAM address
         TXA             ; Bank: 00
         STA $4304       ; Set src HB
         LDA #$02        ; 1Rx2B to PPU
         STA $4300       ; Set DMA mode
         LDA #$04        ; $2104
         STA $4301       ; To OAM
         LDY #$0300      ; 00/0300
         STY $4302       ; Set src LBs
         LDY #$0220      ; Bytes: 544
         STY $4305       ; Set data size
         LDA #$01        ; Channel: 0
         STA $420B       ; Move data
         RTS

; Handle absolute VRAM transfer (NMI)
C314F3:  LDY $14         ; Destination
         STY $2116       ; Set VRAM ptr
         LDA #$01        ; 2Rx1B to PPU
         STA $4300       ; Set DMA mode
         LDA #$18        ; $2118
         STA $4301       ; To VRAM
         LDY $16         ; Source LBs
         STY $4302       ; Set CH0's
         LDA $18         ; Source HB
         STA $4304       ; Set CH0's
         LDY $12         ; Number of bytes
         STY $4305       ; Set data size
         LDA #$01        ; Channel: 0
         STA $420B       ; Move data
         RTS

; Handle conditional VRAM transfer (NMI)
C31517:  LDY $1B         ; Destination
         BEQ C3153C      ; Exit if none
         STY $2116       ; Set VRAM ptr
         LDA #$01        ; 2Rx1B to PPU
         STA $4300       ; Set DMA mode
         LDA #$18        ; $2118
         STA $4301       ; To VRAM
         LDY $1D         ; Source LBs
         STY $4302       ; Set CH0's
         LDA $1F         ; Source HB
         STA $4304       ; Set CH0's
         LDY $19         ; Number of bytes
         STY $4305       ; Set data size
         LDA #$01        ; Channel: 0
         STA $420B       ; Move data
C3153C:  RTS

; Refresh CGRAM (NMI)
C3153D:  LDA $45         ; Menu flags
         BIT #$01        ; Freeze CGRAM?
         BEQ C31568      ; Exit if so
         LDA $00         ; CGRAM: $0000
         STA $2121       ; To BG color 0
         LDA #$02        ; 1Rx2B to PPU
         STA $4300       ; Set DMA mode
         LDA #$22        ; $2122
         STA $4301       ; To CGRAM
         LDY #$3049      ; 7E/3049
         STY $4302       ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $4304       ; Set src HB
         LDY #$0200      ; Bytes: 512
         STY $4305       ; Set data size
         LDA #$01        ; Channel: 0
         STA $420B       ; Move data
C31568:  RTS

; Load save data on defeat
C31569:  LDA $021F       ; File number
         BEQ C3157F      ; Reset if none
         JSR C315CF      ; Load save file
         JSR C31A3A      ; Compute checksum
         JSR C31A54      ; Bad checksum?
         BEQ C3157F      ; Reset game if so
         JSR C315FE      ; Move timer data
         TDC             ; Reset game: No
         BRA C31583      ; Set aftereffect

; Fork: Reset game
C3157F:  SEP #$20        ; ...
         LDA #$FF        ; Reset game: Yes
C31583:  STA $0205       ; Set aftereffect
         TDC             ; ...
         RTL

; Record game data

C31588:  STA $307FF0     ; Set last altered
         STA $0224       ; Set last viewed
         PHA             ; Memorize slot
         LDY $021B       ; Hrs, mins played
         STY $1863       ; To SRAM block
         LDA $021D       ; Seconds played
         STA $1865       ; To SRAM block
         JSR C315EF      ; Move timer data
         JSR C31A3A      ; Compute checksum
         LDY $E7         ; File checksum
         STY $1FFE       ; To SRAM block
         TDC             ; Clear A
         PLA             ; File number
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C315C7,X  ; SRAM pointer
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDY $00         ; RAM index: 0
C315B6:  LDA $1600,Y     ; Game data
         STA $306000,X   ; Save in SRAM
         INX             ; SRAM index +1
         INY             ; RAM index +1
         CPY #$0A00      ; At $2000?
         BNE C315B6      ; Loop if not
         JMP C37817      ; Mark all files

; SRAM pointers
C315C7:  dw $0000        ; Bogus...
         dw $0000        ; Save slot 1
         dw $0A00        ; Save slot 2
         dw $1400        ; Save slot 3

; Load save file
C315CF:  XBA             ; Get HB
         LDA $00         ; Clear it
         XBA             ; File number
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C315C7,X  ; SRAM pointer
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDY $00         ; RAM index: 0
C315E0:  LDA $306000,X   ; Saved data
         STA $1600,Y     ; Copy to RAM
         INX             ; SRAM index +1
         INY             ; RAM index +1
         CPY #$0A00      ; At $2000?
         BNE C315E0      ; Loop if not
         RTS

; Copy event timer data to save area
C315EF:  TDC             ; Clear A
         TAX             ; Index: 0
C315F1:  LDA $1188,X     ; Timer data
         STA $1FA8,X     ; Put in SRAM
         INX             ; Index +1
         CPX #$0018      ; At $11A0?
         BNE C315F1      ; Loop if not
         RTS

; Restore saved event timer data
C315FE:  TDC             ; Clear A
         TAX             ; Index: 0
C31600:  LDA $1FA8,X     ; Timer data
         STA $1188,X     ; Make active
         INX             ; Index +1
         CPX #$0018      ; At $1FC0?
         BNE C31600      ; Loop if not
         RTS

; Load navigation data for Save menu
C3160D:  LDY #C3161C     ; C3/161C
         JMP C30681      ; Load navig data

; Handle D-Pad for Save menu
C31613:  JSR C307B0      ; Handle D-Pad
C31616:  LDY #C31637     ; C3/1637
         JMP C306C3      ; Relocate cursor

; Navigation data for Save menu
C3161C:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $03          ; 3 rows

; Load navigation data for Load menu
C31621:  LDY #C31630     ; C3/1630
         JMP C30681      ; Load navig data

; Handle D-Pad for Load menu
C31627:  JSR C307B0      ; Handle D-Pad
C3162A:  LDY #C31635     ; C3/1635
         JMP C306C3      ; Relocate cursor

; Navigation data for Load menu
C31630:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $04          ; 4 rows

; Cursor positions for Save and Load menus
C31635:  dw $1C08        ; New Game
C31637:  dw $3C08        ; Save file 1
         dw $7408        ; Save file 2
         dw $AC08        ; Save file 3

; Load navigation data for save file confirmation
C3163D:  LDY #C3164C     ; C3/164C
         JMP C30681      ; Load navig data

; Handle D-Pad for save file confirmation
C31643:  JSR C307B0      ; Handle D-Pad
C31646:  LDY #C31651     ; C3/1651
         JMP C306C3      ; Relocate cursor

; Navigation data for save file confirmation
C3164C:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $02          ; 2 rows

; Cursor positions for save file confirmation
C31651:  dw $44BF        ; Yes
         dw $54BF        ; No

; Draw Save menu, load skins, list actor sprites
C31655:  JSR C371BC      ; Clear BG2 map A
         JSR C3169B      ; Handle files
         JSR C33B5B      ; Load skin visuals
         LDY #C31905     ; C3/1905
         JSR C303C4      ; Draw top window
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C31AE1     ; Text pointer
         JSR C30326      ; Draw "Save"
         JMP C318F9      ; Upload tilemaps

; Draw Load menu, load skins, list actor sprites
C31671:  JSR C371BC      ; Clear BG2 map A
         STZ $1D4E       ; Skin: 1st; etc.
         JSR C37350      ; Reset skin colors
         JSR C33B5B      ; Load skin visuals
         LDY #C31905     ; C3/1905
         JSR C303C4      ; Draw top window
         LDA $1D4E       ; Game options
         AND #$70        ; Reset skin, gauge
         STA $1D4E       ; Save changes
         JSR C3169B      ; Handle files
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C31AE7     ; Text pointer
         JSR C30326      ; Draw "New Game"
         JMP C318F9      ; Upload tilemaps

; Output all save files
C3169B:  JSR C373F4      ; Load grayscale
         LDA #$20        ; Channel: 5
         TRB $43         ; Halt HDMA-5
         LDY #$0002      ; Y: 2
         STY $37         ; Set BG1 Y-Pos
         LDY $1D55       ; User font color
         STY $E7         ; Memorize it
         LDY #$7FFF      ; Color: White
         STY $1D55       ; Set user's font
         JSR C340B9      ; Put in palettes
         LDY $E7         ; Original color
         STY $1D55       ; Restore config
         LDA #$01        ; Gradient set: 1
         JSL $D4CA1D     ; Create gradient
         JSR C371A9      ; Clear BG1 map A
         JSR C371D0      ; Clear BG3 map A
         JSR C371DA      ; Clear BG3 map C
         JSR C31915      ; Move game's SRAM

; Fork: Load save file 1
C316CC:  LDA #$01        ; File: 1
         STA $66         ; ...
         JSR C315CF      ; Load save file
         JSR C37087      ; Move party info
         JSR C31A3A      ; Compute checksum
         JSR C31A54      ; Test validity
         STY $91         ; Save checksum
         BEQ C316EB      ; Branch if invalid
         JSR C376F5      ; List char sprites
         JSR C31786      ; Draw file 1 text
         JSR C33BC9      ; Load skin colors
         BRA C316FE      ; Handle file 2

; Fork: Blank file 1
C316EB:  JSR C3192A      ; Restore skin 1
         JSR C376F5      ; Use blank party
         LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31A8D     ; Text pointer
         JSR C302F9      ; Draw "EMPTY"
         JSR C33BC9      ; Load skin 1 pal

; Fork: Load save file 2
C316FE:  LDA #$02        ; File: 2
         STA $66         ; ...
         JSR C315CF      ; Load save file
         JSR C37087      ; Move party info
         JSR C31A3A      ; Compute checksum
         JSR C31A54      ; Test validity
         STY $93         ; Save checksum
         BEQ C3171D      ; Branch if invalid
         JSR C3774C      ; List char sprites
         JSR C31833      ; Draw file 2 text
         JSR C33BDD      ; Load skin colors
         BRA C31730      ; Handle file 3

; Fork: Blank file 2
C3171D:  JSR C3192A      ; Restore skin 1
         JSR C3774C      ; Use blank party
         LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31A95     ; Text pointer
         JSR C302F9      ; Draw "EMPTY"
         JSR C33BDD      ; Load skin 1 pal

; Fork: Load save file 3
C31730:  LDA #$03        ; File: 3
         STA $66         ; ...
         JSR C315CF      ; Load save file
         JSR C37087      ; Move party info
         JSR C31A3A      ; Compute checksum
         JSR C31A54      ; Test validity
         STY $95         ; Save checksum
         BEQ C3174F      ; Branch if invalid
         JSR C37770      ; List char sprites
         JSR C31896      ; Draw file 3 text
         JSR C33BF1      ; Load skin colors
         BRA C31762      ; Draw all windows

; Fork: Blank file 3
C3174F:  JSR C3192A      ; Restore skin 1
         JSR C37770      ; Use blank party
         LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31A9D     ; Text pointer
         JSR C302F9      ; Draw "EMPTY"
         JSR C33BF1      ; Load skin 1 pal

; Fork: Draw windows and upload skins
C31762:  JSR C3192A      ; Restore SRAM
         JSR C33B75      ; Upload skin A
         LDY #C31909     ; C3/1909
         JSR C303C4      ; Draw window A
         JSR C33B91      ; Upload skin B
         LDY #C3190D     ; C3/190D
         JSR C303C4      ; Draw window B
         JSR C33BAD      ; Upload skin C
         LDY #C31911     ; C3/1911
         JSR C303C4      ; Draw window C
         LDY #$1C00      ; Palette: 7
         JMP C303A9      ; Build skin map

; Draw all text for save file 1
C31786:  LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31ABA     ; Text pointer
         JSR C302F9      ; Draw ":"
         LDA $1863       ; Hours played
         JSR C30563      ; Turn into text
         LDX #$7B0D      ; Text position
         JSR C30539      ; Draw hours
         LDA $1864       ; Minutes played
         JSR C3057C      ; Turn into text
         LDX #$7B13      ; Text position
         JSR C30539      ; Draw minutes
         JSR C317B6      ; Draw leader info
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C31AA5     ; Text pointer
         JSR C302F9      ; Draw "TIME"
         RTS

; Draw leader info for save file 1
C317B6:  TDC             ; Clear A
         TAX             ; 1st: Member 1
C317B8:  LDA $69,X       ; Actor in slot
         BMI C317E5      ; Skip if empty
         JSR C31827      ; Get its address
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C31AC6     ; Text pointer
         JSR C302F9      ; Draw "LV"
         LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31AD5     ; Text pointer
         JSR C302F9      ; Draw "/"
         LDY #$3A0F      ; Text position		=== SNES: +40h as no diacritics
         PHY             ; Set name's
         LDX #$7AFD      ; Text position
         PHX             ; Set max HP's
         LDX #$7AF3      ; Text position
         PHX             ; Set HP's
         LDX #$7A81      ; Text position
         PHX             ; Set level's
         BRA C317E8      ; Draw stats
C317E5:  INX             ; Member slot +1
         BRA C317B8      ; Try next member

; Draw leader's stats over save file
C317E8:  LDX $67         ; Actor's address
         LDA $0008,X     ; Level
         JSR C30563      ; Turn into text
         PLX             ; Text position
         JSR C30539      ; Draw 2 digits
         LDY $67         ; Actor's address
         JSR C32C35      ; Truncate HP
         LDA $0009,Y     ; HP LB
         STA $F3         ; Memorize it
         LDA $000A,Y     ; HP HB
         STA $F4         ; Memorize it
         JSR C305B1      ; Turn into text
         PLX             ; Text position
         JSR C30513      ; Draw 4 digits
         LDX $67         ; Actor address
         LDA $000B,X     ; Max HP LB
         STA $F3         ; Memorize it
         LDA $000C,X     ; Max HP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30DFD      ; Cap at 9999
         JSR C305B1      ; Turn into text
         PLX             ; Text position
         JSR C30513      ; Draw 4 digits
         PLY             ; Text position
         JMP C3356A      ; Draw actor name

; Get member's SRAM block address
C31827:  REP #$20        ; 16-bit A
         TXA             ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $6D,X       ; SRAM address
         STA $67         ; Save for later
         SEP #$20        ; 8-bit A
         RTS

; Draw all text for save file 2
C31833:  LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31ABE     ; Text pointer
         JSR C302F9      ; Draw ":"
         LDA $1863       ; Hours played
         JSR C30563      ; Turn into text
         LDX #$7CCD      ; Text position
         JSR C30539      ; Draw 2 digits
         LDA $1864       ; Minutes played
         JSR C3057C      ; Turn into text
         LDX #$7CD3      ; Text position
         JSR C30539      ; Draw 2 digits
         JSR C31863      ; Draw leader info
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C31AAC     ; Text pointer
         JSR C302F9      ; Draw "TIME"
         RTS

; Draw leader info for save file 2
C31863:  TDC             ; Clear A
         TAX             ; 1st: Member 1
C31865:  LDA $69,X       ; Actor in slot
         BMI C31893      ; Skip if empty
         JSR C31827      ; Get its address
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C31ACB     ; Text pointer
         JSR C302F9      ; Draw "LV"
         LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31AD9     ; Text pointer
         JSR C302F9      ; Draw "/"
         LDY #$3BCF      ; Text position		=== SNES: +40h as no diacritics
         PHY             ; Set name's
         LDX #$7CBD      ; Text position
         PHX             ; Set max HP's
         LDX #$7CB3      ; Text position
         PHX             ; Set HP's
         LDX #$7C41      ; Text position
         PHX             ; Set level's
         JMP C317E8      ; Draw stats
C31893:  INX             ; Member slot +1
         BRA C31865      ; Try next member

; Draw all text for save file 3
C31896:  LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31AC2     ; Text pointer
         JSR C302F9      ; Draw ":"
         LDA $1863       ; Hours played
         JSR C30563      ; Turn into text
         LDX #$7E8D      ; Text position
         JSR C30539      ; Draw 2 digits
         LDA $1864       ; Minutes played
         JSR C3057C      ; Turn into text
         LDX #$7E93      ; Text position
         JSR C30539      ; Draw 2 digits
         JSR C318C6      ; Draw leader info
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C31AB3     ; Text pointer
         JSR C302F9      ; Draw "TIME"
         RTS

; Draw leader info for save file 3
C318C6:  TDC             ; Clear A
         TAX             ; 1st: Member 1
C318C8:  LDA $69,X       ; Actor in slot
         BMI C318F6      ; Skip if empty
         JSR C31827      ; Get its address
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C31AD0     ; Text pointer
         JSR C302F9      ; Draw "LV"
         LDA #$20        ; Palette 0
         STA $29         ; Color: White
         LDY #C31ADD     ; Text pointer
         JSR C302F9      ; Draw "/"
         LDY #$3D8F      ; Text position		=== SNES: +40h as no diacritics
         PHY             ; Set name's
         LDX #$7E7D      ; Text position
         PHX             ; Set max HP's
         LDX #$7E73      ; Text position
         PHX             ; Set HP's
         LDX #$7E01      ; Text position
         PHX             ; Set level's
         JMP C317E8      ; Draw stats
C318F6:  INX             ; Member slot +1
         BRA C318C8      ; Try next member

; Upload tilemaps for Save or Load menu
C318F9:  JSR C30E93      ; Upload BG1 A+B
         JSR C30EBD      ; Upload BG2 A+B
         JSR C30ED9      ; Upload BG3 A+B
         JMP C30EE7      ; Upload BG3 C+D

; Window layout for Save and Load menus
C31905:  dw $58CB,$021C  ; 30x4 at $58CB (Top window)
C31909:  dw $59CB,$051C  ; 30x7 at $59CB (File A)
C3190D:  dw $5B8B,$051C  ; 30x7 at $5B8B (File B)
C31911:  dw $5D4B,$051C  ; 30x7 at $5D4B (File C)

; Back up SRAM block
C31915:  LDY #$AC8D      ; 7E/AC8D
         STY $2181       ; Set WRAM LBs
         LDX $00         ; Index: 0
C3191D:  LDA $1600,X     ; SRAM data
         STA $2180       ; Put in WRAM
         INX             ; Index +1
         CPX #$0A00      ; At $2000?
         BNE C3191D      ; Loop if not
         RTS

; Restore SRAM block
C3192A:  LDX $00         ; Index: 0
C3192C:  LDA $7EAC8D,X   ; Data backup
         STA $1600,X     ; Restore it
         INX             ; Index +1
         CPX #$0A00      ; At 7E/B68D?
         BNE C3192C      ; Loop if not
         RTS

; Set to condense BG3 text (save file confirmation, Colosseum matchup)
C3193A:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C31959     ; C3/1959
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Text shifting table for the above
C31959:  db $20,$00,$00  ; 32 lines, shift by 0 px
         db $0C,$04,$00  ; 12 lines, shift by 4 px
         db $0C,$08,$00  ; 12 lines, shift by 8 px
         db $08,$C8,$FF  ; 8 lines, shift by -38 px
         db $50,$00,$00  ; 80 lines, shift by 0 px
         db $58,$00,$00  ; 88 lines, shift by 0 px
         db $00          ; End

; Create actor sprites for Save or Load menu
C3196C:  LDX $00         ; Actor slot: 1
C3196E:  LDA $7EAA71,X   ; Empty slot?
         BMI C319E0      ; Skip if so
         PHX             ; Save slot
         PHX             ; Save slot
         LDA #$03        ; Min slot: 24
         LDY #C31A30     ; C3/1A30
         JSR C311DE      ; Queue OAM fn
         TXY             ; Queue index
         PLX             ; Actor slot
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDA $66         ; On "New Game"?
         BEQ C3199A      ; Branch if so
         CMP #$01        ; On file 1?
         BEQ C319AC      ; Branch if so
         CMP #$02        ; On file 2?
         BEQ C319A3      ; Branch if so
         LDA.L C31A24,X  ; OAM complements
         STA $3749,Y     ; Set sprite's
         BRA C319B3      ; Set coords/ptr

; Fork: New Game
C3199A:  LDA.L C31A00,X  ; OAM complements
         STA $3749,Y     ; Set sprite's
         BRA C319B3      ; Set coords/ptr

; Fork: Save file 2
C319A3:  LDA.L C31A18,X  ; OAM complements
         STA $3749,Y     ; Set sprite's
         BRA C319B3      ; Set coords/ptr

; Fork: Save file 1
C319AC:  LDA.L C31A0C,X  ; OAM complements
         STA $3749,Y     ; Set sprite's
C319B3:  LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set anim ptr HB
         TDC             ; Clear A
         STA $33CB,Y     ; No use...
         STA $344B,Y     ; No use...
         LDA.L C319E8,X  ; X position
         STA $33CA,Y     ; Set sprite's
         LDA.L C319F4,X  ; Y position
         STA $344A,Y     ; Set sprite's
         LDA $7EAA71,X   ; Graphics set
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA $D8E9A1,X   ; Anim table ptr		=== SNES: $D8E917
         STA $32C9,Y     ; Set sprite's
         SEP #$20        ; 8-bit A
         PLB             ; Restore DB
         PLX             ; Actor slot
C319E0:  INX             ; Point to next
         CPX #$000C      ; Done all 12?
         BNE C3196E      ; Loop if not
         SEC             ; ...
         RTS

; X positions for actors on save files
C319E8:  dw $6850,$9880  ; File 1
         dw $6850,$9880  ; File 2
         dw $6850,$9880  ; File 3

; Y positions for actors on save files
C319F4:  dw $4040,$4040  ; File 1
         dw $7878,$7878  ; File 2
         dw $B0B0,$B0B0  ; File 3

; Actors' OAM complements when on "New Game"
C31A00:  dw $0202,$0202  ; File 1: Grayscale
         dw $0202,$0202  ; File 2: Grayscale
         dw $0202,$0202  ; File 3: Grayscale

; Actors' OAM complements when on save file 1
C31A0C:  dw $0000,$0000  ; File 1: None
         dw $0202,$0202  ; File 2: Grayscale
         dw $0202,$0202  ; File 3: Grayscale

; Actors' OAM complements when on save file 2
C31A18:  dw $0202,$0202  ; File 1: Grayscale
         dw $0000,$0000  ; File 2: None
         dw $0202,$0202  ; File 3: Grayscale

; Actors' OAM complements when on save file 3
C31A24:  dw $0202,$0202  ; File 1: Grayscale
         dw $0202,$0202  ; File 2: Grayscale
         dw $0000,$0000  ; File 3: None

; Display actor's sprite on save file
C31A30:  LDX $2D         ; Queue index
         JSR C31271      ; Set pose timer
         JSR C3128C      ; Define OAM
         CLC             ; Set to dequeue
         RTS

; Compute SRAM checksum
C31A3A:  STZ $E7         ; Sum LB: 0
         STZ $E8         ; Sum HB: 0
         LDX $00         ; Index: 0
         CLC             ; Prepare ADC
C31A41:  LDA $1600,X     ; SRAM data
         ADC $E7         ; Add sum LB
         STA $E7         ; Set sum LB
         TDC             ; Clear A
         ADC $E8         ; Add HB + C
         STA $E8         ; Set sum HB
         INX             ; Index +1
         CPX #$09FE      ; At checksum?
         BNE C31A41      ; Loop if not
         RTS

; Load and validate SRAM checksum (buggy if zero)
C31A54:  REP #$20        ; 16-bit A
         LDA $E7         ; Actual checksum
         CMP $1FFE       ; Sum in save file
         BNE C31A5F      ; Use 0 if unalike
         BRA C31A60      ; Skip a line
C31A5F:  TDC             ; Clear checksum
C31A60:  TAY             ; Put sum in Y
         SEP #$20        ; 8-bit A
         RTS

; 53: Queue fade-out for save menu
C31A64:  JSR C330EA      ; Queue fade-out
         LDY #$0008      ; Frames: 8
         STY $20         ; Set fade timer
         LDA #$54        ; C3/1A82
         STA $26         ; Next: Wait
         JMP C3196C      ; Refresh actors

; 52: Queue fade-in for save menu
C31A73:  JSR C330F1      ; Queue fade-in
         LDY #$0008      ; Frames: 8
         STY $20         ; Set fade timer
         LDA #$54        ; C3/1A82
         STA $26         ; Next: Wait
         JMP C3196C      ; Create actors

; 54: Wait while save menu fades in or out
C31A82:  LDY $20         ; Timer expired?
         BNE C31A8A      ; Branch if not
         LDA $27         ; Queued command
         STA $26         ; Execute it next
C31A8A:  JMP C3196C      ; Refresh actors

; Positioned text for save menus
C31A8D:  dw $7A4F : db "EMPTY",$00			=== SNES: Not fully capitalized (below too)
C31A95:  dw $7C0F : db "EMPTY",$00
C31A9D:  dw $7DCF : db "EMPTY",$00
C31AA5:  dw $7ACF : db "TIME",$00
C31AAC:  dw $7C8F : db "TIME",$00
C31AB3:  dw $7E4F : db "TIME",$00
C31ABA:  dw $7B11 : db ":",$00
C31ABE:  dw $7CD1 : db ":",$00
C31AC2:  dw $7E91 : db ":",$00
C31AC6:  dw $7A7B : db "LV",$00
C31ACB:  dw $7C3B : db "LV",$00
C31AD0:  dw $7DFB : db "LV",$00
C31AD5:  dw $7AFB : db "/",$00
C31AD9:  dw $7CBB : db "/",$00
C31ADD:  dw $7E7B : db "/",$00
C31AE1:  dw $7925 : db |セーブ[end]|	; Save		=== SNES: +40h as no diacritics; shifted rightward
C31AE7:  dw $7923 : db |ニューゲーム[end]|	; New Game	=== SNES: +40h as no diacritics

; 04: Initialize main menu
C31AF0:  JSR C335F7      ; Reset/Stop stuff
         JSR C31C0E      ; Load portraits
         JSR C30FF4      ; Stop VRAM DMA B
         JSR C33B3F      ; Set Win2 bounds
         LDA #$04        ; Channel: 2
         TSB $43         ; Queue Win1 HDMA
         JSR C30FF4      ; Again...
         JSR C37076      ; Reset BGs' X/Y
         LDA #$03        ; 64x64 at $0000
         STA $2107       ; Set BG1 map loc
         LDA #$43        ; 64x64 at $4000
         STA $2109       ; Set BG3 map loc
         LDA #$C0        ; Channels: 6, 7
         TRB $43         ; Halt HDMA 6+7
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         JSR C33190      ; Draw menu
         LDA #$00        ; Min slot: 0
         LDY #C32FDD     ; C3/2FDD
         JSR C311DE      ; Queue D-Pad fn
         JSR C30833      ; Queue cursor OAM
         JSR C33616      ; HDMA: MS desig.
         LDY #$0002      ; Y: 2
         STY $37         ; Set BG1 Y-Pos
         JSR C3376B      ; Set to shift BG3
         LDA #$05        ; C3/1E0A
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 07: Initialize Item menu
C31B3C:  JSR C31B48      ; Init list vars
         JSR C31B64      ; Draw menu; cursor
         JSR C31B74      ; Shift & OBJ & Fade
         JMP C31B94      ; Queue: Choice 1

; Initialize item list variables (Item, Colosseum)
C31B48:  JSR C335F7      ; Reset/Stop stuff
         JSR C31BFF      ; Queue desc anim
         JSR C37076      ; Reset BGs' X/Y
         STZ $4A         ; List scroll: 0
         STZ $49         ; Top BG1 WR row: 1
         LDA #$76        ; Top row: 119th		=== SNES: 246
         STA $5C         ; Set scroll limit
         LDA #$0A        ; Onscreen rows: 10
         STA $5A         ; Set rows per page
         LDA #$02        ; Onscreen cols: 2		=== SNES: 1
         STA $5B         ; Set cols per page
         JMP C384A3      ; Load navig data

; Draw Item menu, position cursor in inventory
C31B64:  LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C31B6E      ; Branch if not
         JSR C30E17      ; Restore cursor
C31B6E:  JSR C384AC      ; Relocate cursor
         JMP C38552      ; Draw menu; elems

; Initiate text shifting, sprites, fade-in (Item, Colosseum)
C31B74:  JSR C385DA      ; Set to shift text
         JSR C30833      ; Queue cursor OAM
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$00EA      ; V-Speed: 0.914 px		=== SNES: 0.44
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0058      ; Y: 88
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         RTS

; Queue Item menu choice 1, prepare fade-in
C31B94:  LDA #$08        ; C3/1F5D
         STA $27         ; Queue: Choice 1
         JMP C33609      ; BRT:1 + NMI

; 77: Return from item usage menu
C31B9B:  JSR C31B48      ; Init list vars
         LDA $8E         ; Old cursor column
         STA $4D         ; Set onscreen col
         LDY $8E         ; Old cursor loc
         STY $4F         ; Set as current
         LDA $90         ; Old scroll pos
         STA $4A         ; Set as current
         LDA $4A         ; ...
         STA $E0         ; Memorize it...
         LDA $50         ; List row
         SEC             ; Prepare SBC
         SBC $E0         ; Sub scroll pos
         STA $4E         ; Set cursor row
         JSR C384AC      ; Relocate cursor
         JSR C38552      ; Draw menu; elems
         JSR C31B74      ; Shift & OBJ & Fade
         JMP C31B94      ; Queue: Choice 1

; 09: Initialize Skills menu
C31BC1:  JSR C335F7      ; Reset/Stop stuff
         TDC             ; Clear A
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $69,X       ; Actor in slot
         JSL $C20006     ; Get actor stats
         JSR C31C0E      ; Load portraits
         JSR C3719C      ; Set Win1 bounds
         STZ $4A         ; List scroll: 0
         STZ $49         ; Top BG1 WR row: 1
         JSR C35482      ; Set to shift text
         JSR C3533D      ; Draw menu, etc.
         JSR C35213      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C31BEB      ; Branch if not
         JSR C30E6A      ; Restore cursor
C31BEB:  JSR C3521C      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C31BFF      ; Queue desc anim
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$0A        ; C3/205A
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; Set to update and upload description
C31BFF:  JSR C3B0D9      ; Clear desc GFX
         JSR C3B301      ; Queue desc upload
         LDA #$00        ; Min slot: 0
         LDY #C3B151     ; C3/B151
         JSR C311DE      ; Queue desc update
         RTS

; Load portrait graphics and colors for party
C31C0E:  JSR C37087      ; Get party info
         JSR C37616      ; Load graphics
         JSR C3739D      ; Load colors
         LDA #$05        ; Show cursor: Y
         TSB $45         ; Unfreeze CGRAM
         JMP C3153D      ; Refresh CGRAM

; 35: Initialize Equip menu
C31C1E:  JSR C31C23      ; Init variables
         BRA C31C3D      ; Draw menu, etc.

; Initialize variables for Equip menu
C31C23:  JSR C335F7      ; Reset/Stop stuff
         JSR C3719C      ; Set Win1 bounds
         LDA #$06        ; Main cursor: On
         TSB $46         ; Set menu flag
         STZ $4A         ; List scroll: 0
         STZ $49         ; Top BG1 WR row: 1
         JSR C39CA5      ; Set to shift text
         JSR C395C5      ; Load navig data
         JSR C395CE      ; Relocate cursor
         JMP C30833      ; Queue cursor OAM

; Draw Equip menu, update status based on gear, trigger fade-in
C31C3D:  JSR C397DB      ; Draw menu; status
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$36        ; C3/9E10
         STA $27         ; Queue: Option list
         JMP C33609      ; BRT:1 + NMI

; 7E: Swap actor in Equip menu, retain Equip mode
C31C4B:  JSR C31C67      ; Draw menu, etc.
         JSR C39E3E      ; Draw blue "EQUIP"
         JSR C31C70      ; Cursor & Fade-in
         LDA #$55        ; C3/A073
         JMP C31C7B      ; Queue slot choice

; 7F: Swap actor in Equip menu, retain Remove mode
C31C59:  JSR C31C67      ; Draw menu, etc.
         JSR C39E45      ; Draw blue "REMOVE"
         JSR C31C70      ; Cursor & Fade-in
         LDA #$56        ; C3/A0BE
         JMP C31C7B      ; Queue slot choice

; Redraw Equip menu after actor swap
C31C67:  JSR C31C23      ; Reset variables
         JSR C397DB      ; Draw menu; status
         JMP C39E03      ; Switch windows

; Put cursor on first gear slot, trigger fade-in
C31C70:  JSR C395E1      ; Load navig data
         JSR C395EA      ; Relocate cursor
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         RTS

; Set queued menu command, prepare fade-in
C31C7B:  STA $27         ; Set queued cmd
         JMP C33609      ; BRT:1 + NMI

; 6D: Open Equip menu after optimizing gear
C31C80:  JSR C31C23      ; Init variables
         JSR C39EDF      ; Optimize gear
         LDA #$02        ; Menu: Equip
         STA $25         ; Set submenu
         BRA C31C3D      ; Draw menu, etc.

; 6E: Open Equip menu after removing all gear
C31C8C:  JSR C31C23      ; Init variables
         JSR C39E97      ; Remove gear
         LDA #$02        ; Menu: Equip
         STA $25         ; Set submenu
         BRA C31C3D      ; Draw menu, etc.

; 38: Initialize party gear overview
C31C98:  JSR C335F7      ; Reset/Stop stuff
         JSR C39C86      ; Set to shift text
         JSR C39662      ; Draw menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$39        ; C3/29D0
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; 0B: Initialize Status menu
C31CAC:  JSR C335F7      ; Reset/Stop stuff
         JSR C36854      ; Set to shift text
         JSR C36362      ; Draw menu; portrait
         JSR C31CC3      ; Init cursor data
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$0C        ; C3/2255
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; Initialize cursor data for Status menu
C31CC3:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         LDA $0000,Y     ; Actor
         CMP #$0C        ; Gogo?
         BNE C31CDE      ; Abort if not
         JSR C337C7      ; Load navig data
         JSR C337D0      ; Relocate cursor
         LDA #$06        ; Main cursor: On
         TSB $46         ; Set menu flag
         JMP C30833      ; Queue cursor OAM
C31CDE:  LDA #$06        ; Main cursor: Off
         TRB $46         ; Set menu flag
         RTS

; 0D: Initialize Config menu
C31CE3:  JSR C335F7      ; Reset/Stop stuff
         STZ $4A         ; Screen: 1st
         JSR C33B20      ; Set Win2 bounds
         JSR C3396F      ; Draw menu, etc.
         JSR C33927      ; Load navig data
         LDA $5F         ; Return position
         STA $4E         ; Set cursor row
         JSR C33930      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$0E        ; C3/2325
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; 13: Initialize Save menu
C31D06:  JSR C335F7      ; Reset/Stop stuff
         LDY #$0002      ; Y: 2
         STY $37         ; Set BG1 Y-Pos
         JSR C3376B      ; Set to shift BG3...
         LDA #$E3        ; CH: 0-1, 5-7
         TRB $43         ; Halt HDMA channels
         JSR C31655      ; Draw menu, get chars
         JSR C3745B      ; Load actor colors
         JSR C37418      ; Load cursor colors
         JSR C3160D      ; Load navig data
         LDY $91         ; File 1 checksum
         BNE C31D2D      ; Branch if not 0
         LDY $93         ; File 2 checksum
         BNE C31D2D      ; Branch if not 0
         LDY $95         ; File 3 checksum
         BEQ C31D33      ; Branch if 0
C31D2D:  LDA $0224       ; Last viewed file
         DEC A           ; Now 0-2
         STA $4E         ; Set cursor row
C31D33:  JSR C31616      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         LDA $4B         ; Cursor slot
         INC A           ; Now 1-3
         STA $66         ; Set active file
         LDA #$52        ; C3/1A73
         STA $26         ; Next: Fade-in
         LDA #$14        ; C3/25B3
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; 15: Initialize save confirmation
C31D49:  JSR C335F7      ; Reset/Stop stuff
         JSR C37087      ; Get party info
         JSR C331C3      ; Draw menu
         JSR C3163D      ; Load navig data
         JSR C31646      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C3193A      ; Set to shift text
         LDA #$16        ; C3/2610
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 20: Initialize Load menu
C31D69:  JSR C335F7      ; Reset/Stop stuff
         LDY #$0002      ; Y: 2
         STY $37         ; Set BG1 Y-Pos
         JSR C3376B      ; Set to shift BG3...
         LDA #$E3        ; CH: 0-1, 5-7
         TRB $43         ; Halt HDMA channels
         LDY $00         ; X: 0
         STY $35         ; Set BG1 X-Pos
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         JSR C31671      ; Draw menu, get chars
         JSR C3745B      ; Load actor colors
         JSR C37418      ; Load cursor colors
         JSR C31621      ; Load navig data
         LDY $91         ; File 1 checksum
         BNE C31D9C      ; Branch if not 0
         LDY $93         ; File 2 checksum
         BNE C31D9C      ; Branch if not 0
         LDY $95         ; File 3 checksum
         BEQ C31DA2      ; Branch if 0
C31D9C:  LDA $307FF0     ; Last altered file
         STA $4E         ; Set cursor row
C31DA2:  JSR C3162A      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         LDA $4B         ; Cursor slot
         STA $66         ; Set active file
         LDA #$21        ; C3/2A5D
         STA $27         ; Queue: Sustain menu
         LDA #$52        ; C3/1A73
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 22: Initialize load confirmation
C31DB7:  JSR C335F7      ; Reset/Stop stuff
         JSR C37087      ; Get party info
         JSR C331E7      ; Draw menu
         JSR C3163D      ; Load navig data
         JSR C31646      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C3193A      ; Set to shift text
         LDA #$23        ; C3/2AC5
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 00: Queue fade-out, prepare transition
C31DD7:  JSR C330EA      ; Queue fade-out
         LDY #$0008      ; Frames: 8
         STY $20         ; Set fade timer
         LDA #$02        ; C3/1DF1
         STA $26         ; Next: Wait
         RTS

; 01: Queue fade-in, prepare transition
C31DE4:  JSR C330F1      ; Queue fade-in
         LDY #$0008      ; Frames: 8
         STY $20         ; Set fade timer
         LDA #$02        ; C3/1DF1
         STA $26         ; Next: Wait
         RTS

; 02: Wait while menu fades in or out
C31DF1:  LDY $20         ; Timer expired?
         BNE C31DF9      ; Exit if not
         LDA $27         ; Queued command
         STA $26         ; Execute it next
C31DF9:  RTS

; 03: Exit main menu's portrait area
C31DFA:  LDA #$00        ; Min slot: 0
         LDY #C32FDD     ; C3/2FDD
         JSR C311DE      ; Queue D-Pad fn
         JSR C30833      ; Queue cursor OAM
         LDA #$05        ; C3/1E0A
         STA $26         ; Next: Main menu
         RTS

; 05: Sustain main menu
C31E0A:  JSR C33610      ; Redraw time
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C31E16      ; Branch if not
         JMP C32EFD      ; Handle selection

; Fork: Handle left
C31E16:  LDA $09         ; No-autofire keys
         BIT #$02        ; Pushing left?
         BEQ C31E22      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         JMP C32F61      ; Init Order menu

; Fork: Handle B
C31E22:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C31E37      ; Exit if not
         STZ $0205       ; Clear field event
         JSR C30F14      ; Sound: Cursor
         JSR C31E38      ; Update field FX
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
C31E37:  RTS

; Update field effects from gear (Charms, Sprint Shoes)
C31E38:  STZ $11DF       ; Clear effects
         LDX $00         ; Member slot: 1
C31E3D:  LDA $69,X       ; Actor in slot
         BMI C31E47      ; Skip if none
         PHX             ; Save slot
         JSL $C20006     ; Load gear FX
         PLX             ; Member slot
C31E47:  INX             ; Slot +1
         CPX #$0004      ; Done all 4?
         BNE C31E3D      ; Loop if not
         RTS

; 06: Handle single actor targeting in main menu
C31E4E:  JSR C33610      ; Redraw time
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C31E63      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$05        ; Blinker: Off
         TRB $46         ; Actor cursor: Off
         LDA #$03        ; C3/1DFA
         STA $26         ; Next: Main menu
         RTS

; Fork: Handle MT mode switch
C31E63:  LDA $09         ; No-autofire keys
         BIT #$02        ; Pushing left?
         BEQ C31E85      ; Branch if not
         LDA $25         ; Selected menu
         CMP #$02        ; Equip?
         BEQ C31E73      ; Branch if so
         CMP #$03        ; Relic?
         BNE C31E85      ; Branch if not
C31E73:  JSR C30F0E      ; Sound: Cursor
         LDA #$06        ; Main cursor: Off
         TRB $46         ; Set menu flag
         LDA #$37        ; C3/1F1B
         STA $26         ; Next: Target all
         LDA $4E         ; Cursor row
         STA $5E         ; Set return loc
         JMP C30924      ; Create blinkers

; Fork: Handle A
C31E85:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C31E92      ; Exit if not
         LDA $4B         ; Cursor slot
         STA $28         ; Set member slot
         JMP C31E93      ; Skip a line
C31E92:  RTS             ; Exit
C31E93:  JSR C31EB4      ; Can open menu?
         BCS C31EA8      ; Fail if not
         TDC             ; Clear A
         LDA $25         ; Menu to open
         TAX             ; Index it
         LDA.L C31EAF,X  ; Init command
         STA $27         ; Put in queue
         STZ $26         ; Next: Fade-out
         JSR C30F1D      ; Sound: Click
         RTS

; Fork: Inaccessible menu
C31EA8:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Initialization commands for actor menus
C31EAF:  db $FF          ; Blank
         db $09          ; Skills
         db $35          ; Equip
         db $58          ; Relic
         db $0B          ; Status

; Determine if actor-related menu is accessible
C31EB4:  TDC             ; Clear A
         LDA $25         ; Menu to open
         CMP #$01        ; Skills?
         BEQ C31EEF      ; Branch if so
         CMP #$02        ; Equip?
         BEQ C31EC5      ; Branch if so
         CMP #$03        ; Relic?
         BEQ C31EDA      ; Branch if so
         BRA C31F19      ; Allow access

; Fork: Equip
C31EC5:  TDC             ; ...
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA $6D,X       ; Actor's address
         SEP #$20        ; 8-bit A
         TAX             ; Index it
         LDA $0000,X     ; Actor
         CMP #$0D        ; Umaro or guest?
         BCS C31F17      ; Fail if so
         BRA C31F02      ; Check if dead

; Fork: Relic
C31EDA:  TDC             ; ...
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA $6D,X       ; Actor's address
         SEP #$20        ; 8-bit A
         TAX             ; Index it
         LDA $0000,X     ; Actor
         CMP #$0E        ; Guest?
         BCS C31F17      ; Fail if so
         BRA C31F02      ; Check if dead

; Fork: Skills
C31EEF:  JSR C353FD      ; Set skill colors
         LDA #$24        ; Palette: Gray
         LDX $00         ; 1st: Espers
C31EF6:  CMP $79,X       ; Grayed skill?
         BNE C31F02      ; Branch if not
         INX             ; Skill slot +1
         CPX #$0007      ; Beyond Dance?
         BNE C31EF6      ; Loop if not
         BRA C31F17      ; Play buzzer

; Fork: Check if dead
C31F02:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA $6D,X       ; Actor address
         SEP #$20        ; 8-bit A
         TAX             ; Index it
         LDA $0014,X     ; Zombie? KO?
         AND #$C2        ; Or Petrify?
         BNE C31F17      ; Fail if any
         BRA C31F19      ; Allow access

; Fork: Set to play buzzer
C31F17:  SEC             ; Mark failure
         RTS

; Fork: Set to open menu
C31F19:  CLC             ; Mark success
         RTS

; 37: Handle multitargeting in main menu
C31F1B:  JSR C33610      ; Redraw time
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BNE C31F2A      ; Branch if so
         LDA $09         ; ...
         BIT #$01        ; Pushing right?
         BEQ C31F4B      ; Branch if not
C31F2A:  JSR C30F14      ; Sound: Cursor
         JSR C33033      ; Preload nav data
         JSR C30833      ; Queue cursor OAM
         LDA #$00        ; Min slot: 0
         LDY #C3305B     ; C3/305B
         JSR C311DE      ; Queue D-Pad fn
         JSR C3121B      ; Run anim queue
         LDA $5E         ; Old cursor row
         STA $4E         ; Set as current
         LDA #$06        ; C3/1E4E
         STA $26         ; Next: ST actor
         LDA #$08        ; Blinkers: Off
         TRB $46         ; Set menu flag
         RTS

; Fork: Handle A
C31F4B:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C31F5B      ; Exit if not
         JSR C30F1D      ; Sound: Click
         STZ $26         ; Next: Fade-out
         LDA #$38        ; C3/1C98
         STA $27         ; Queue: Party gear
         RTS             ; ...
C31F5B:  RTS             ; ...
C31F5C:  RTS

; 08: Handle Item menu choice 1
C31F5D:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         TDC             ; Clear A
         STA $2A         ; List type: Stock
         JSR C30F68      ; Queue list upload
         JSR C31FCA      ; Handle L and R
         BCS C31F5C      ; Exit if pushed
         JSR C384A9      ; Handle D-Pad
         JSR C38A72      ; Load description

; Fork: Handle B
C31F72:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C31FA1      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDY $4F         ; Cursor position
         STY $022F       ; To cursor memory
         LDA $4A         ; Scroll position
         STA $0231       ; To cursor memory
         JSR C3852F      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C31F94      ; Branch if not
         LDY $0234       ; Former position
         STY $4D         ; Set as current
C31F94:  JSR C38535      ; Relocate cursor
         LDA #$17        ; C3/2667
         STA $26         ; Next: Option list
         JSR C38B06      ; Blank item count
         JMP C30FA4      ; Queue its upload

; Fork: Handle A
C31FA1:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C31FB5      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; List slot
         STA $28         ; Set choice 1's
         LDA #$19        ; C3/27EC
         STA $26         ; Next: Choice 2
         JMP C32FBC      ; Create blinker
C31FB5:  RTS

; Hi-fork: Pressed L on first page
C31FB6:  STZ $50         ; List row: 1
         STZ $4E         ; Cursor row: 1
         SEC             ; Mark L/R usage
         RTS

; Hi-fork: Pressed R on last page
C31FBC:  LDA $54         ; Bottom menu row
         DEC A           ; Adjust value
         STA $4E         ; Set cursor row
         CLC             ; Prepare ADC
         ADC $4A         ; Add scroll pos
         STA $50         ; Set list row
         SEC             ; Mark L/R usage
         RTS

; Hi-fork: Do nothing
C31FC8:  CLC             ; Mark no L/R use
         RTS

; Handle L and R for scrollable list
C31FCA:  LDA $20         ; Scrolling now?
         BNE C31FC8      ; Exit if so
         LDA $0A         ; Semi-auto keys
         BIT #$10        ; Pushing R?
         BEQ C31FF9      ; Branch if not
         LDA $4A         ; Scroll position
         CMP $5C         ; At very bottom?
         BEQ C31FBC      ; Branch if so
         LDA $5C         ; Scroll limit
         SEC             ; Prepare SBC
         SBC $4A         ; Get rows left
         CMP $5A         ; Full page below?
         BCS C31FE5      ; Branch if so
         BRA C31FE7      ; Skip a line
C31FE5:  LDA $5A         ; Rows per page
C31FE7:  STA $E0         ; Set shift qty
         LDA $4A         ; Scroll position
         CLC             ; Prepare ADC
         ADC $E0         ; Add shift qty
         STA $4A         ; Save changes
         LDA $50         ; List row
         CLC             ; Prepare ADC
         ADC $E0         ; Add shift qty
         STA $50         ; Save changes
         BRA C3201D      ; Redraw & Sound

; Fork: Handle L
C31FF9:  LDA $0A         ; Semi-auto keys
         BIT #$20        ; Pushing L?
         BEQ C31FC8      ; Exit if not
         LDA $4A         ; On first page?
         BEQ C31FB6      ; Branch if so
         CMP $5A         ; Full page above?
         BCS C3200B      ; Branch if so
         LDA $4A         ; Scroll position
         BRA C3200D      ; Skip a line
C3200B:  LDA $5A         ; Rows per page
C3200D:  STA $E0         ; Set shift qty
         LDA $4A         ; Scroll position
         SEC             ; Prepare SBC
         SBC $E0         ; Sub shift qty
         STA $4A         ; Save changes
         LDA $50         ; List row
         SEC             ; Prepare SBC
         SBC $E0         ; Sub shift qty
         STA $50         ; Save changes

; Fork: Redraw list, play sound effect
C3201D:  JSR C30F0E      ; Sound: Cursor
         TDC             ; Clear A
         LDA $2A         ; List type
         ASL A           ; Double it
         TAX             ; Index it
         JSR (C3202A,X)  ; Redraw list
         SEC             ; Mark L/R usage
         RTS

; Jump table for the above
C3202A:  dw C32036       ; Inventory
         dw C3203C       ; Magic
         dw C32042       ; Lore
         dw C32048       ; Rage
         dw C3204E       ; Esper
         dw C32054       ; Gear

; Redraw inventory for page swap (Item, Colosseum, Sell)
C32036:  JSR C38644      ; Load V-shift data
         JMP C38737      ; Draw inventory

; Redraw Magic list for page swap
C3203C:  JSR C354F3      ; Load V-shift data
         JMP C35659      ; Draw spell list

; Redraw Lore list for page swap
C32042:  JSR C354F3      ; Load V-shift data
         JMP C3590B      ; Draw Lore list

; Redraw Rage list for page swap
C32048:  JSR C354F3      ; Load V-shift data
         JMP C35A02      ; Draw Rage list

; Redraw Esper list for page swap
C3204E:  JSR C354F3      ; Load V-shift data
         JMP C35AC6      ; Draw esper list

; Redraw gear list for page swap (Equip, Relic)
C32054:  JSR C39D0F      ; Load V-shift data
         JMP C3A49B      ; Draw item list

; 0A: Sustain Skills menu
C3205A:  LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         JSR C35219      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32075      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle A
C32075:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32082      ; Branch if not
         LDA $4E         ; Cursor row
         STA $5E         ; Set return loc
         JMP C320EA      ; Invoke submenu

; Fork: Handle L and R, prepare for menu reset
C32082:  LDA #$09        ; C3/1BC1
         STA $E0         ; Set init command
         BRA C32088      ; ...

; Handle member switching with L or R (excludes Status menu)



C32088:  LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BEQ C320B9      ; Branch if not
         LDA $25         ; Submenu
         CMP #$03        ; Relic?
         BNE C3209F      ; Branch if not
         JSR C3A6F9      ; Handle Reequip
         LDA $99         ; Triggered it?
         BEQ C3209F      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Switch to next member
C3209F:  TDC             ; Clear A
         LDA $28         ; Current member
         INC A           ; Point to next
         AND #$03        ; Wrap if last
         STA $28         ; Save changes
         TAX             ; Index it
         LDA $69,X       ; Nobody there?
         BMI C3209F      ; Skip if so
         JSR C31EB4      ; Can access menu?
         BCS C3209F      ; Skip if not
         LDA $E0         ; Init command
         STA $26         ; Set menu mode
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Handle L
C320B9:  LDA $08         ; No-autofire keys
         BIT #$20        ; Pushing L?
         BEQ C320E9      ; Exit if not
         LDA $25         ; Submenu
         CMP #$03        ; Relic?
         BNE C320D0      ; Branch if not
         JSR C3A6F9      ; Handle Reequip
         LDA $99         ; Triggered it?
         BEQ C320D0      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Switch to preceding member
C320D0:  TDC             ; Clear A
         LDA $28         ; Current member
         DEC A           ; Point to previous
         AND #$03        ; Wrap if was first
         STA $28         ; Save changes
         TAX             ; Index it
         LDA $69,X       ; Nobody there?
         BMI C320D0      ; Skip if so
         JSR C31EB4      ; Can access menu?
         BCS C320D0      ; Skip if not
         LDA $E0         ; Init command
         STA $26         ; Set menu mode
         JSR C30F0E      ; Sound: Cursor
C320E9:  RTS

; Initialize selected Skills submenu if accessible
C320EA:  TDC             ; Clear A
         LDA $4B         ; Chosen menu
         TAX             ; Index it
         LDA $79,X       ; Name's color
         CMP #$20        ; User's color?
         BNE C320FE      ; Fail if not
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; Chosen menu
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C32105,X)  ; Invoke menu

; Fork: Play buzzer
C320FE:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Jump table for the above
C32105:  dw C32113       ; Espers
         dw C3217C       ; Magic
         dw C3214E       ; SwdTech
         dw C32165       ; Blitz
         dw C321CE       ; Lore
         dw C32206       ; Rage
         dw C3223E       ; Dance

; Initialize Espers menu
C32113:  STZ $4A         ; List scroll: 0
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$1333      ; V-Speed: 19.2 px		=== SNES: 16
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0060      ; Y: 96			=== SNES: 104
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         JSR C352CD      ; Load navig data
         JSR C352D6      ; Relocate cursor
         LDA #$05        ; Top row: Carb.'s		=== SNES: 6
         STA $5C         ; Set scroll limit
         LDA #$09        ; Onscreen rows: 9		=== SNES: 8
         STA $5A         ; Set rows per page
         LDA #$02        ; Onscreen cols: 2
         STA $5B         ; Set cols per page
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C35AAC      ; Draw espers, etc.
         LDA #$1E        ; C3/2946
         STA $26         ; Next: Sustain menu
         JSR C32F86      ; Create blinker
         RTS

; Initialize SwdTech menu
C3214E:  STZ $4A         ; List scroll: 0
         JSR C352A7      ; Load navig data
         JSR C352B0      ; Relocate cursor
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C359B0      ; Draw techs, etc.
         LDA #$3E        ; C3/29F8
         STA $26         ; Next: Sustain menu
         RTS

; Initialize Blitz menu
C32165:  STZ $4A         ; List scroll: 0
         JSR C352A7      ; Load navig data
         JSR C352B0      ; Relocate cursor
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C35C2D      ; Draw inputs, etc.
         LDA #$33        ; C3/29E1
         STA $26         ; Next: Sustain menu
         RTS

; Initialize Magic menu
C3217C:  JSR C32190      ; Create scrollbar
         JSR C321A8      ; Load nav data, etc.
         JSR C321B8      ; Draw spells, etc.
         JSR C35895      ; Draw MP cost
         JSR C30FB8      ; Queue BG3 upload
         LDA #$1A        ; C3/2855
         STA $26         ; Next: Sustain menu
         RTS

; Create scrollbar for Magic menu
C32190:  STZ $4A         ; List scroll: 0
         JSR C309A4      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA #$08BA      ; V-Speed: 8.73 px		=== SNES: 5.05
         STA $7E354A,X   ; Set sprite's
         LDA #$0060      ; Y: 96			=== SNES: 104
         STA $7E34CA,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Load navigation data for Magic menu; position cursor
C321A8:  JSR C35245      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C321B5      ; Branch if not
         JSR C30E75      ; Restore cursor
C321B5:  JMP C3524E      ; Relocate cursor

; Switch to Magic menu, create portrait, draw spells and "MP.."		=== SNES: "MP…"
C321B8:  LDA #$0B        ; Top row: Quake's		=== SNES: Sleep's
         STA $5C         ; Set scroll limit
         LDA #$09        ; Onscreen rows: 9		=== SNES: 8
         STA $5A         ; Set rows per page
         LDA #$03        ; Onscreen cols: 3		=== SNES: 2
         STA $5B         ; Set cols per page
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JMP C3543F      ; Draw spells, etc.

; Initialize Lore menu
C321CE:  STZ $4A         ; List scroll: 0
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$2000      ; V-Speed: 32 px		=== SNES: 6
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0060      ; Y: 96			=== SNES: 104
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         JSR C352CD      ; Load navig data
         JSR C352D6      ; Relocate cursor
         LDA #$03        ; Top row: Big Guard		=== SNES: 16
         STA $5C         ; Set scroll limit
         LDA #$09        ; Onscreen rows: 9		=== SNES: 8
         STA $5A         ; Set rows per page
         LDA #$02        ; Onscreen cols: 2		=== SNES: 1
         STA $5B         ; Set cols per page
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C358C8      ; Draw lores, etc.
         LDA #$1B        ; C3/28FD
         STA $26         ; Next: Sustain menu
         RTS

; Initialize Rage menu
C32206:  STZ $4A         ; List scroll: 0
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$00CE      ; V-Speed: 0.8 px		=== SNES: #$00CC
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0060      ; Y: 96			=== SNES: 104
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         JSR C35305      ; Load navig data
         JSR C3530E      ; Relocate cursor
         LDA #$77        ; Top row: Mandrake		=== SNES: #$78
         STA $5C         ; Set scroll limit
         LDA #$09        ; Onscreen rows: 9		=== SNES: 8
         STA $5A         ; Set rows per page
         LDA #$02        ; Onscreen cols: 2
         STA $5B         ; Set cols per page
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C359EC      ; Draw rages, etc.
         LDA #$1D        ; C3/292D
         STA $26         ; Next: Sustain menu
         RTS

; Initialize Dance menu
C3223E:  STZ $4A         ; List scroll: 0
         JSR C352A7      ; Load navig data
         JSR C352B0      ; Relocate cursor
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C35DD1      ; Draw dances, etc.
         LDA #$1C        ; C3/291D
         STA $26         ; Next: Sustain menu
         RTS

; 0C: Sustain Status menu
C32255:  JSR C30FA4      ; Set to redraw cmds
         LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BEQ C3227E      ; Branch if not
         LDA $28         ; Member slot
         STA $79         ; Set former slot
C32262:  TDC             ; Clear A
         LDA $28         ; Member slot
         INC A           ; Point to next
         AND #$03        ; Wrap if was last
         STA $28         ; Save changes
         TAX             ; Index slot
         LDA $69,X       ; Nobody there?
         BMI C32262      ; Skip slot if so
         LDA $28         ; New member slot
         CMP $79         ; Matches former?
         BEQ C32278      ; Skip sound if so
         JSR C30F0E      ; Sound: Cursor
C32278:  JSR C31CC3      ; Init cursor data
         JMP C363E0      ; Swap actor info

; Fork: Handle L
C3227E:  LDA $08         ; No-autofire keys
         BIT #$20        ; Pushing L?
         BEQ C322A4      ; Branch if not
         LDA $28         ; Member slot
         STA $79         ; Set former slot
C32288:  TDC             ; Clear A
         LDA $28         ; Member slot
         DEC A           ; Point to previous
         AND #$03        ; Wrap if was first
         STA $28         ; Save changes
         TAX             ; Index it
         LDA $69,X       ; Empty slot?
         BMI C32288      ; Loop if so
         LDA $28         ; New member slot
         CMP $79         ; Matches former?
         BEQ C3229E      ; Skip sound if so
         JSR C30F0E      ; Sound: Cursor
C3229E:  JSR C31CC3      ; Init cursor data
         JMP C363E0      ; Swap actor info

; Fork: Handle B
C322A4:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C322B4      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle Gogo
C322B4:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         LDA $0000,Y     ; Actor
         CMP #$0C        ; Gogo?
         BNE C32313      ; Exit if not
         JSR C337CD      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32313      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; Cursor slot
         STA $E7         ; Memorize it
         STZ $E8         ; Clear HB
         TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         REP #$20        ; 16-bit A
         TYA             ; Move it to A
         CLC             ; Prepare ADC
         ADC $E7         ; Add cursor slot
         TAY             ; Index sum
         SEP #$20        ; 8-bit A
         LDA $0016,Y     ; Chosen command
         CMP #$12        ; Mimic?
         BEQ C32313      ; Exit if so
         JSR C32FA1      ; Create blinker
         LDA $4E         ; Cursor row
         STA $5E         ; Set return loc
         LDA $4B         ; Cursor slot
         STA $64         ; Set altered slot
         LDA #$06        ; Frames: 6
         STA $20         ; Set scroll timer
         LDY #$000C      ; Speed: 12
         STY $9C         ; Set scroll speed
         LDA #$6A        ; C3/69F0
         STA $27         ; Queue: Shifted menu
         LDA #$65        ; C3/37AF
         STA $26         ; Next: Shift screen
         JSR C36A4C      ; Load navig data
         LDA $7E9D89     ; Command list size
         STA $54         ; Set number of rows
         JMP C36A55      ; Relocate cursor
C32313:  RTS

; Menu command 6B (unused)
C32314:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32324      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS             ; ...
C32324:  RTS

; 0E: Sustain Config menu
C32325:  JSR C30F54      ; Queue list upload
         LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C32340      ; Branch if not
         LDA $4E         ; Cursor row
         CMP #$09        ; On Controller?		=== SNES: 8 (no Button Settings menu)
         BNE C32340      ; Branch if not
         LDA #$50        ; C3/3AD4
         STA $26         ; Next: Scroll
         LDA #$11        ; Frames: 17
         STA $20         ; Set scroll timer
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Handle upward scrolling
C32340:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C3235A      ; Branch if not
         LDA $4E         ; On top row?
         BNE C3235A      ; Branch if not
         LDA $4A         ; On first page?
         BEQ C3235A      ; Branch if so
         LDA #$51        ; C3/3AF5
         STA $26         ; Next: Scroll
         LDA #$11        ; Frames: 17
         STA $20         ; Set scroll timer
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Handle B and D-Pad
C3235A:  LDA $4A         ; On first page?
         BEQ C32363      ; Branch if so
         JSR C33955      ; Handle P2 D-Pad
         BRA C32366      ; Skip a line
C32363:  JSR C3392D      ; Handle P1 D-Pad
C32366:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32376      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle left and right
C32376:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C32382      ; Branch if so
         LDA $0B         ; ...
         BIT #$02        ; Pushing left?
         BEQ C32385      ; Branch if not
C32382:  JMP C33E34      ; Change settings

; Fork: Handle A
C32385:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3238E      ; Branch if not
         JMP C32391      ; Handle click

; Fork: Handle L and R
C3238E:  JMP C3245F      ; Handle L and R

; Fork: Handle clicked option
C32391:  LDA $4E         ; Cursor row
         STA $5F         ; Set return row
         LDA $4A         ; On first page?
         BNE C323A2      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C323AA,X)  ; Handle option

; Waste of space...
C323A1:  RTS

; Fork: Handle click on page 2
C323A2:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C323BE,X)  ; Handle option

; Jump table for clicks in Config menu
C323AA:  dw C323A1       ; Bat.Mode   (NOP)
         dw C323A1       ; Bat.Speed  (NOP)
         dw C323A1       ; Msg.Speed  (NOP)
         dw C323CA       ; Cmd.Set
         dw C323A1       ; Gauge      (NOP)
         dw C323A1       ; Sound      (NOP)
         dw C323A1       ; Cursor     (NOP)
         dw C323A1       ; Reequip    (NOP)
         dw C323DB       ; Buttton			%%%
         dw C323EC       ; Controller
C323BE:  dw C323A1       ; Mag.Order  (NOP)
         dw C323A1       ; Window     (NOP)
         dw C323FB       ; Color
         dw C323FB       ; R
         dw C323FB       ; G
         dw C323FB       ; B

; Handle click on "Short" option
C323CA:  LDA $1D4D       ; Game options
         BIT #$80        ; Short cmd set?
         BEQ C323A1      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA #$47        ; C3/43A3
         STA $27         ; Queue cmd menu
         STZ $26         ; Next: Fade-out
         RTS

; Handle click on "Custom" option			%%%
C323DB:  LDA $1D54       ; Game options
         BIT #$40        ; Custom buttons?
         BEQ C323A1      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA #$49        ; C3/478E
         STA $27         ; Queue key menu
         STZ $26         ; Next: Fade-out
         RTS

; Handle click on "Multiple" option
C323EC:  LDA $1D54       ; Multiplayer mode?
         BPL C323A1      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA #$4B        ; C3/47E2
         STA $27         ; Queue joypad menu
         STZ $26         ; Next: Fade-out
         RTS

; Handle color resetting in options
C323FB:  JSR C30F1D      ; Sound: Click
         LDA $1D54       ; Game options
         AND #$38        ; Get viewed color
         BEQ C3240E      ; Branch if font
         JSR C3241A      ; Reset skin colors
         JSR C33B5B      ; Refresh skin
         JMP C342A4      ; Redraw RGB info

; Fork: Reset font color
C3240E:  LDY #$7FFF      ; Color: White
         STY $1D55       ; Put in options
         JSR C340B9      ; Put in palettes
         JMP C342A4      ; Redraw RGB info

; Reset skin palette
C3241A:  TDC             ; Clear A
         LDA $1D4E       ; Game options
         AND #$0F        ; Get wallpaper
         REP #$20        ; 16-bit A
         TAY             ; Set loop counter
         STZ $EB         ; RAM index: 0
         STZ $ED         ; ROM index: 0
C32427:  DEY             ; Counter -1
         BMI C3243C      ; Branch if < 0
         LDA #$000E      ; RAM struct size
         CLC             ; Prepare ADC
         ADC $EB         ; Add RAM index
         STA $EB         ; Set RAM index
         LDA #$0020      ; ROM struct size
         CLC             ; Prepare ADC
         ADC $ED         ; Add ROM index
         STA $ED         ; Set ROM index
         BRA C32427      ; Loop

; Fork: Load skin palette
C3243C:  LDX #$312B      ; 7E/312B
         STX $2181       ; Set WRAM LBs
         LDA $EB         ; RAM index
         TAY             ; Index it
         LDA $ED         ; ROM index
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA #$0E        ; Colors: 7
         STA $E9         ; Set counter
C3244E:  LDA $ED1C02,X   ; Color data
         STA $1D57,Y     ; Put in options
         STA $2180       ; Put in palette
         INX             ; ROM index +1
         INY             ; RAM index +1
         DEC $E9         ; One less byte
         BNE C3244E      ; Loop till last
         RTS

; Handle L and R in Config menu
C3245F:  LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BNE C32469      ; Branch if so
         BIT #$20        ; Pushing L?
         BEQ C3247E      ; Exit if not
C32469:  JSR C30F0E      ; Sound: Cursor
         STZ $5F         ; Return loc...
         LDA $4A         ; On first page?
         BNE C32479      ; Branch if not
         LDA #$01        ; Screen: 2nd
         STA $4A         ; Set active page
         JMP C33ABE      ; Switch screens

; Fork: On page 2
C32479:  STZ $4A         ; Page: 1st
         JSR C33AC9      ; Switch screens
C3247E:  RTS

; 0F: Handle Order menu choice 1
C3247F:  JSR C33610      ; Redraw time
         JSR C370FB      ; Set SRAM party
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BNE C32491      ; Branch if so
         LDA $09         ; ...
         BIT #$01        ; Pushing right?
         BEQ C324AA      ; Branch if not
C32491:  JSR C30F14      ; Sound: Cursor
         LDA #$06        ; Frames: 6
         STA $20         ; Set scroll timer
         LDY #$000C      ; Speed: 12
         STY $9C         ; Set scroll speed
         LDA #$05        ; Blinker: Off
         TRB $46         ; Order cursor: Off
         LDA #$03        ; C3/1DFA
         STA $27         ; Queue: Main menu
         LDA #$65        ; C3/37AF
         STA $26         ; Next: Pan screen
         RTS

; Fork: Handle A
C324AA:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C324C5      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; Selected slot
         STA $28         ; Set choice 1
         LDA #$10        ; C3/24C6
         STA $26         ; Next: Choice 2
         JSR C32FBC      ; Create blinker
         JSR C3304C      ; Unlock all slots
         LDA $4E         ; Cursor row
         STA $5E         ; Save for cancel
C324C5:  RTS

; 10: Handle Order menu choice 2
C324C6:  JSR C33610      ; Redraw time
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C324E2      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$0F        ; C3/247F
         STA $26         ; Next: Choice 1
         JSR C33033      ; Lock empty slots
         LDA $5E         ; Old cursor row
         STA $4E         ; Set as current
         RTS

; Fork: Change row
C324E2:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3251B      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA $28         ; First selection
         CMP $4B         ; Matches second?
         BNE C32504      ; Swap if not
         LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$12        ; C3/25AA
         STA $26         ; Next: Wait
         JSR C32EAB      ; Set row, scroll
         LDY #$000C      ; Frames: 12
         STY $20         ; Set wait timer
         JMP C33033      ; Lock empty slots

; Fork: Switch members
C32504:  LDA #$10        ; Cursor: Freeze
         TRB $46         ; Set menu flag
         LDA #$0C        ; Cursor: Blank
         TRB $45         ; Unhide chars: N
         JSR C3364A      ; Queue swap anim
         LDA #$18        ; Frames: 24
         STA $22         ; Set anim timer
         LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$11        ; C3/251C
         STA $26         ; Next: Sustain swap
C3251B:  RTS

; 11: Switch members in Order menu
C3251C:  JSR C33610      ; Redraw time
         LDA $22         ; Timer expired?
         BEQ C32553      ; Finalize if so
         CMP #$0C        ; Unhide point?
         BNE C32560      ; Exit if not
         JSR C3256B      ; Swap battle pads
         JSR C32E6C      ; Swap actor info
         JSR C32561      ; Clear icons/faces
         JSR C371A9      ; Erase party info
         JSR C3338C      ; Draw member 1 info
         JSR C333D8      ; Draw member 2 info
         JSR C33424      ; Draw member 3 info
         JSR C33470      ; Draw member 4 info
         JSR C30E25      ; Swap saved cursors
         JSR C30F68      ; Queue stats upload
         JSR C33033      ; Lock empty slots
         JSR C3121B      ; Run anim queue
         JSR C313D3      ; Refresh screen
         LDA #$08        ; Unhide members: Y
         TSB $45         ; Set menu flag
         RTS

; Fork: Restore control
C32553:  LDA #$0F        ; C3/247F
         STA $26         ; Next: Choice 1
         LDA #$10        ; Cursor: Unfreeze
         TSB $46         ; Set menu flag
         LDA #$04        ; Show cursor: Y
         TSB $45         ; Set menu flag
         RTS             ; ...
C32560:  RTS

; Delete all portraits and status icons
C32561:  JSR C32ED7      ; Portraits: Erase
         LDA #$01        ; Icons: Delete
         TRB $47         ; Set menu flag
         JMP C3121B      ; Run anim queue

; Swap assigned joypad for switched members
C3256B:  TDC             ; Clear A
         TAX             ; Member slot: 1
         STX $E0         ; Char 1+2: Pad 1
         STX $E2         ; Char 3+4: Pad 1
         LDA $1D4F       ; Game options
         CLC             ; Prepare ROR
C32575:  ROR A           ; Member's joypad
         BCC C3257A      ; Skip if Pad 1
         INC $E0,X       ; Assign Pad 2
C3257A:  INX             ; Member slot +1
         CPX #$0004      ; Done all 4?
         BNE C32575      ; Loop if not
         TDC             ; Clear A
         LDA $4B         ; Chosen slot B
         TAX             ; Index it
         LDA $E0,X       ; Member B's pad
         STA $E5         ; Memorize it
         LDA $28         ; Chosen slot A
         TAX             ; Index it
         LDA $E0,X       ; Member A's pad
         STA $E6         ; Memorize it
         LDA $E5         ; Member B's pad
         STA $E0,X       ; Set as A's
         LDA $4B         ; Chosen slot B
         TAX             ; Index it
         LDA $E6         ; Member A's pad
         STA $E0,X       ; Set as B's
         CLC             ; ...
         LDA $E3         ; Member 4's pad
         ASL A           ; Put in bit 1
         ADC $E2         ; Add member 3's
         ASL A           ; Put in bit 1-2
         ADC $E1         ; Add member 2's
         ASL A           ; Put in bit 1-3
         ADC $E0         ; Add member 1's
         STA $1D4F       ; Update options
         RTS

; 12: Wait while member changes row
C325AA:  LDY $20         ; Timer expired?
         BNE C325B2      ; Exit if not
         LDA #$0F        ; C3/247F
         STA $26         ; Next: Choice 1
C325B2:  RTS

; 14: Sustain Save menu
C325B3:  LDA $4B         ; Cursor slot
         INC A           ; Now 1-3
         STA $66         ; Set save slot
         JSR C3196C      ; Refresh actors
         JSR C31613      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C325D0      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA $9F         ; 04: C3/1AF0
         STA $27         ; Queue main menu
         LDA #$53        ; C3/1A64
         STA $26         ; Next: Fade-out
         RTS

; Fork: Handle A
C325D0:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3260F      ; Exit if not
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $91,X       ; Blank file?
         BNE C325F3      ; Branch if not
         LDA $66         ; Save slot
         STA $021F       ; Link to game
         JSR C30F24      ; Sound: Save
         JSR C32652      ; Save game
         LDA $9E         ; Menu init cmd
         STA $27         ; Queue Save menu
         LDA #$53        ; C3/1A64
         STA $26         ; Next: Fade-out
         RTS

; Fork: Invoke confirmation menu
C325F3:  JSR C30F1D      ; Sound: Click
         JSR C31915      ; Back up SRAM data
         LDA $4B         ; Cursor slot
         INC A           ; Now 1-3
         STA $66         ; Set save slot
         JSR C315CF      ; Load save file
         JSR C37087      ; Move party info
         JSR C370FB      ; Set SRAM party
         LDA #$15        ; C3/1D49
         STA $27         ; Queue submenu
         LDA #$53        ; C3/1A64
         STA $26         ; Next: Fade-out
C3260F:  RTS

; 16: Sustain save confirmation
C32610:  JSR C31643      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BNE C32635      ; Abort if so
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32651      ; Exit if not
         LDA $4B         ; Chose "No"?
         BNE C3263A      ; Abort if so
         LDA $66         ; Save slot
         STA $021F       ; Link to game
         JSR C30F24      ; Sound: Save
         JSR C32652      ; Save game
         LDA $9E         ; 13: C3/1D06
         STA $27         ; Queue Save menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Pushing B
C32635:  JSR C30F14      ; Sound: Cursor
         BRA C3263D      ; Skip a line

; Fork: Chose "No"
C3263A:  JSR C30F1D      ; Sound: Click
C3263D:  JSR C3192A      ; Restore SRAM
         JSR C37087      ; And party info
         JSR C370FB      ; Set SRAM party
         LDA #$13        ; C3/1D06
         STA $27         ; Queue Save menu
         STZ $26         ; Next: Fade-out
         LDA $66         ; File number
         STA $0224       ; Set last viewed
C32651:  RTS

; Restore SRAM block and record game data
C32652:  JSR C3192A      ; Restore SRAM
         JSR C37087      ; And party info
         JSR C370FB      ; Set SRAM party
         REP #$20        ; 16-bit A
         INC $1DC7       ; Save count +1
         SEP #$20        ; 8-bit A
         LDA $66         ; File number
         JMP C31588      ; Save game data

; 17: Handle Item menu options
C32667:  LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         JSR C30F68      ; Queue stock upload
         JSR C3853B      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32684      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
C32684:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32690      ; Exit if not
         JSR C30F1D      ; Sound: Click
         JSR C32691      ; Handle choice
C32690:  RTS

; Handle selected Item menu option
C32691:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C32699,X)  ; Handle option

; Jump table for the above
C32699:  dw C3269F       ; USE
         dw C326EF       ; ARRANGE
         dw C32701       ; RARE

; Handle "USE" selection in Item menu
C3269F:  JSR C384A3      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C326AE      ; Branch if not
         JSR C30E17      ; Restore cursor
         BRA C326BE      ; Skip cursor reset
C326AE:  LDA $0231       ; Old scroll pos
         STA $4A         ; Set as current
         LDY $4D         ; Cursor position
         STY $4F         ; Set as list loc
         LDA $4A         ; Scroll position
         CLC             ; Prepare ADC
         ADC $50         ; Add list V-Slot
         STA $50         ; Set list V-Slot
C326BE:  JSR C384AC      ; Relocate cursor
         JSR C385BC      ; Draw inventory
         JSR C38A72      ; Desc; item count
         JSR C30FA4      ; Queue BG3 upload
         JSR C313D3      ; Refresh screen
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$00EA      ; V-Speed: 0.914 px		=== SNES: 0.44
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0058      ; Y: 88
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         LDA #$08        ; C3/1F5D
         STA $26         ; Next: Choice 1
         LDA #$00        ; Min slot: 0
         LDY #C3B151     ; C3/B151
         JSR C311DE      ; Queue desc update
         RTS

; Handle "ARRANGE" selection in Item menu
C326EF:  JSR C371A9      ; Hide inventory
         JSR C3272B      ; Move inventory
         JSR C32753      ; Sort inventory
         JSR C38737      ; Redraw inventory
         JSR C3852F      ; Load navig data
         JMP C31F94      ; Move cursor, etc.

; Initialize rare item menu
C32701:  JSR C384DF      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C32710      ; Branch if not
         LDY $0232       ; Former position
         STY $4D         ; Set as current
C32710:  JSR C384E8      ; Relocate cursor
         JSR C38B0C      ; Draw item list
         JSR C31BFF      ; Queue desc anim
         JSR C38ABA      ; Get desc/draw count
         JSR C30FA4      ; Queue count upload
         JSR C313D3      ; Refresh screen
         LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         LDA #$18        ; C3/27B4
         STA $26         ; Next: Sustain menu
         RTS

; Relocate inventory for sorting, delete original
C3272B:  TDC             ; ...
         TAX             ; Item slot: 1
C3272D:  LDA $1869,X     ; Item in slot
         STA $7EAA8D,X   ; Put in buffer
         LDA #$FF        ; Empty item
         STA $1869,X     ; Clear slot
         INX             ; Item slot +1
         CPX #$0100      ; Done all 256?
         BNE C3272D      ; Loop if not
         TDC             ; Clear A
         TAX             ; Item slot: 1
C32741:  LDA $1969,X     ; Item quantity
         STA $7EAB8D,X   ; Put in buffer
         TDC             ; Quantity: 0
         STA $1969,X     ; Clear original
         INX             ; Item slot +1
         CPX #$0100      ; Done all 256?
         BNE C32741      ; Loop if not
         RTS

; Sort inventory based on item icons
C32753:  TDC             ; Clear A
         TAY             ; Item slot: 1
         TAX             ; Icon index: 0
C32756:  LDA.L C32768,X  ; Item icon
         PHX             ; Save index
         STA $E0         ; Set class
         JSR C32779      ; Get such items
         PLX             ; Icon index
         INX             ; Index +1
         CPX #$0011      ; Done 17 icons?
         BNE C32756      ; Loop if not
         RTS

; Ordered list of item icons for Arrange command
C32768:  db $FF          ; No icon
         db $E3          ; Dirk				=== SNES: Different tile numbers
         db $E4          ; Sword
         db $E5          ; Lance
         db $E6          ; Knife
         db $E7          ; Rod
         db $E8          ; Brush
         db $E9          ; Stars
         db $EA          ; Special
         db $EB          ; Gambler
         db $EC          ; Claw
         db $ED          ; Shield
         db $F0          ; Helmet
         db $F1          ; Armor
         db $F2          ; Tool
         db $F3          ; Skean
         db $F4          ; Relic

; Copy all items with given icon from buffer to inventory
C32779:  TDC             ; Clear A
         TAX             ; Buffer slot: 1
C3277B:  PHX             ; Save buffer slot
         LDA $7EAA8D,X   ; Item in slot
         CMP #$FF        ; None?
         BEQ C327AC      ; Skip if so
         STA $4202       ; Set multiplicand
         LDA #$09        ; Name length			=== SNES: 13
         STA $4203       ; Set multiplier
         NOP
         NOP
         NOP
         LDX $4216       ; Index product
         LDA $E6F700,X   ; Item icon			=== SNES: $D2B300
         CMP $E0         ; Sought type?
         BNE C327AC      ; Skip if not
         PLX             ; Buffer slot
         LDA $7EAA8D,X   ; Item in slot
         STA $1869,Y     ; Put in stock
         LDA $7EAB8D,X   ; Item quantity
         STA $1969,Y     ; Put in stock
         INY             ; Stock slot +1
         BRA C327AD      ; Skip a line
C327AC:  PLX             ; Buffer slot
C327AD:  INX             ; Buffer slot +1
         CPX #$0100      ; Done all 256?
         BNE C3277B      ; Loop if not
         RTS

; 18: Sustain rare item menu
C327B4:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         JSR C30F68      ; Queue list upload
         JSR C384E5      ; Handle D-Pad
         JSR C38ABA      ; Get desc/draw count
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C327EB      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA #$17        ; C3/2667
         STA $26         ; Next: Option list
         LDY $4D         ; Cursor position
         STY $0232       ; To cursor memory
         JSR C3852F      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C327E2      ; Branch if not
         LDY $0234       ; Former position
         STY $4D         ; Set as current
C327E2:  JSR C38535      ; Relocate cursor
         JSR C38B06      ; Blank item count
         JMP C30FA4      ; Queue its upload
C327EB:  RTS

; 19: Handle Item menu choice 2
C327EC:  JSR C30F68      ; Queue list upload
         JSR C384A9      ; Handle D-Pad
         JSR C38A72      ; Load description
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32807      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$08        ; C3/1F5D
         STA $26         ; Next: Choice 1
         RTS

; Fork: Handle A
C32807:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32854      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA $28         ; First selection
         CMP $4B         ; Matches second?
         BNE C3281D      ; Swap them if not
         LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         JMP C38C22      ; Handle item

; Fork: Switch items
C3281D:  LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$08        ; C3/1F5D
         STA $26         ; Next: Choice 1
         TDC             ; Clear A
         LDA $28         ; Slot A
         TAY             ; Index it
         LDA $1869,Y     ; Item A
         STA $E0         ; Save it
         LDA $1969,Y     ; Quantity A
         STA $E1         ; Save it
         TDC             ; ...
         LDA $4B         ; Slot B
         TAX             ; Index it
         LDA $1869,X     ; Item B
         STA $1869,Y     ; Replace A
         LDA $E0         ; Item A
         STA $1869,X     ; Replace B
         LDA $1969,X     ; Quantity B
         STA $1969,Y     ; Replace A
         LDA $E1         ; Quantity A
         STA $1969,X     ; Replace B
         JMP C38737      ; Redraw list
C32854:  RTS

; 1A: Sustain Magic menu
C32855:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         LDA #$01        ; List type: Magic
         STA $2A         ; Set redraw mode
         JSR C30F68      ; Queue list upload
         LDA $021E       ; Frame counter
         ROR A           ; Even value?
         BCC C3286B      ; Favor desc if so
         JSR C30FE0      ; Queue cost upload
         BRA C3286E      ; Skip a line
C3286B:  JSR C3B301      ; Queue desc upload
C3286E:  JSR C31FCA      ; Handle L and R
         BCS C328D4      ; Exit if pushed
         JSR C3524B      ; Handle D-Pad
         JSR C35D42      ; Load description
         JSR C35895      ; Draw MP cost

; Fork: Handle Y
C3287C:  LDA $09         ; No-autofire keys
         BIT #$40        ; Pushing Y?
         BEQ C32895      ; Branch if not
         JSR C30F1D      ; Sound: Click
         LDA $9E         ; MP display switch
         EOR #$FF        ; Toggle it
         STA $9E         ; Save changes
         LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         JSR C355EB      ; Build spell list
         JMP C35659      ; Draw spell list

; Fork: Handle A
C32895:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C328C8      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; Spell slot
         TAX             ; Index it
         LDA $7E9E09,X   ; Spell palette
         CMP #$20        ; User's color?
         BNE C328D5      ; Fail if not
         JSR C30F1D      ; Sound: Click
         LDY $4F         ; Cursor position
         STY $8E         ; Set return loc
         LDA $4A         ; Scroll position
         STA $90         ; Set return loc
         LDA $4B         ; Cursor slot
         STA $99         ; Set spell slot
         JSR C32DAE      ; Spell
         CMP #$12        ; X-Zone?
         BEQ C328DC      ; Branch if so
         CMP #$2A        ; Warp?
         BEQ C328E7      ; Branch if so
         LDA #$3A        ; C3/2B00
         STA $27         ; Queue usage menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle B
C328C8:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C328D4      ; Exit if not
         JSR C30F68      ; Queue BG1 upload
         JSR C32A40      ; Exit submenu
C328D4:  RTS

; Fork: Unusable spell
C328D5:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Fork: X-Zone (unused)
C328DC:  LDA $0201       ; Area permissions
         BIT #$01        ; Forbid X-Zone?
         BEQ C328D5      ; Fail if so
         LDA #$04        ; Event: X-Zone
         BRA C328F0      ; Lower caster's MP

; Fork: Warp
C328E7:  LDA $0201       ; Area permissions
         BIT #$02        ; Can warp here?
         BEQ C328D5      ; Fail if not
         LDA #$03        ; Event: Warp
C328F0:  STA $0205       ; Set aftereffect
         JSR C32D85      ; Lower caster's MP
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS

; 1B: Sustain Lore menu
C328FD:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         LDA #$02        ; List type: Lores
         STA $2A         ; Set redraw mode
         JSR C30F68      ; Queue list upload
         JSR C31FCA      ; Handle L and R
         BCS C3291C      ; Exit if pushed
         JSR C352D3      ; Handle D-Pad
         JSR C35D48      ; Load description
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3291C      ; Exit if not
         JSR C32A40      ; Leave submenu
C3291C:  RTS

; 1C: Sustain Dance menu
C3291D:  JSR C30F68      ; Queue list upload
         JSR C352AD      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3292C      ; Exit if not
         JSR C32A40      ; Leave submenu
C3292C:  RTS

; 1D: Sustain Rage menu
C3292D:  LDA #$03        ; List type: Rages
         STA $2A         ; Set redraw mode
         JSR C30F68      ; Queue list upload
         JSR C31FCA      ; Handle L and R
         BCS C32945      ; Exit if pushed
         JSR C3530B      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32945      ; Exit if not
         JSR C32A40      ; Leave submenu
C32945:  RTS

; 1E: Handle esper selection
C32946:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         LDA #$04        ; List type: Espers
         STA $2A         ; Set redraw mode
         JSR C30F68      ; Queue list upload
         JSR C31FCA      ; Handle L and R
         BCS C3299B      ; Exit if pushed
         JSR C352D3      ; Handle D-Pad
         JSR C35D3C      ; Load description
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3298E      ; Branch if not
         JSR C30F1D      ; Sound: Click
         TDC             ; Clear A
         LDA $4B         ; Selected slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Esper in slot
         CMP #$FF        ; None?
         BEQ C3297B      ; Unequip if so
         STA $99         ; Memorize esper
         JSR C35EEC      ; Init submenu
         LDA #$4D        ; C3/5F23
         STA $26         ; Next: Data menu
         RTS

; Fork: Unequip esper
C3297B:  LDA #$FF        ; Value for empty
         STA $E0         ; Set esper to equip
         JSR C3299C      ; Clear esper held
         JSR C35AC6      ; Redraw esper list
         JSR C30F7C      ; Queue stats upload
         JSR C313D3      ; Refresh held esper
         JMP C30F68      ; Queue list upload

; Fork: Handle B
C3298E:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3299B      ; Exit if not
         LDA #$08        ; Blinker: Off
         TRB $46         ; Set menu flag
         JSR C32A40      ; Leave submenu
C3299B:  RTS

; Equip and draw selected esper
C3299C:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         LDA $E0         ; Chosen esper
         STA $001E,Y     ; Assign to actor
         LDA $E0         ; ...
         JMP C355D7      ; Draw it by actor

; 34: Wait while showing who holds esper
C329AD:  LDY $20         ; Timer expired?
         BNE C329BA      ; Exit if not
         LDY #C329BB     ; Text pointer
         JSR C30326      ; Blank message
         JMP C35F68      ; Exit submenu
C329BA:  RTS

; Positioned spaces for blanking "<actor> has it!"
C329BB:  dw $40DD : db "                  ",$00		=== SNES: Shifted leftward and longer

; 39: Sustain party gear overview
C329D0:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C329E0      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS             ; ...
C329E0:  RTS

; 33: Sustain Blitz menu
C329E1:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         JSR C30F68      ; Queue list upload
         JSR C352AD      ; Handle D-Pad
         JSR C35D72      ; Load description
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C329F7      ; Exit if not
         JSR C32A40      ; Leave submenu
C329F7:  RTS

; 3E: Sustain SwdTech menu
C329F8:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         JSR C30F68      ; Queue list upload
         JSR C352AD      ; Handle D-Pad
         JSR C35D5D      ; Load description
         LDA $08         ; No-autofire keys		%%%
         BIT #$80        ; Pushing A?
         BEQ C32A2A      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9D89,X   ; SwdTech in slot
         BMI C32A24      ; Fail if none
         STA $0206       ; Set chosen tech
         LDA #$FF        ; SwdTech renaming
         STA $0205       ; Set next menu
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Invalid selection				%%%
C32A24:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen

; Fork: Handle B
C32A2A:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32A3F      ; Exit if not
         JSR C371D5      ; Clear BG3 map B		%%%
         JSR C3AFC5      ; Build desc map
         JSR C30FB8      ; Queue its upload
         JSR C313D3      ; Upload it now
         JSR C32A40      ; Leave submenu
C32A3F:  RTS

; Return to Skills menu
C32A40:  JSR C30F14      ; Sound: Cursor
         LDY $00         ; X: 0
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         LDA #$0A        ; C3/205A
         STA $26         ; Next: Skills menu
         JSR C353E7      ; Erase spell list
         JSR C35213      ; Load navig data
         LDA $5E         ; Old cursor row
         STA $4E         ; Set as current
         JSR C3521C      ; Relocate cursor
         JMP C35E66      ; Remove portrait

; 21: Sustain Load menu
C32A5D:  LDA $4B         ; Cursor slot
         STA $66         ; Set save slot
         JSR C3196C      ; Refresh actors
         JSR C31627      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32AA1      ; Exit if not
         TDC             ; Clear A
         LDA $4B         ; On new game?
         BEQ C32AA2      ; Branch if so
         STA $66         ; Set save slot
         DEC A           ; Now 0-2
         ASL A           ; Double it
         TAX             ; Index it
         LDY $91,X       ; Blank file?
         BEQ C32A9B      ; Fail if so
         JSR C31915      ; Back up SRAM data
         JSR C30F1D      ; Sound: Click
         LDA $66         ; Chosen save file
         STA $0224       ; Set last viewed
         JSR C315CF      ; Load save file
         JSR C37087      ; Move party info
         JSR C370FB      ; Set SRAM party
         JSR C315FE      ; Move timer data
         LDA #$22        ; C3/1DB7
         STA $27         ; Queue confirm menu
         LDA #$53        ; C3/1A64
         STA $26         ; Next: Fade-out
         RTS

; Fork: Blank file
C32A9B:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
C32AA1:  RTS

; Fork: New game
C32AA2:  JSR C30F1D      ; Sound: Click
         JSR C32ABC      ; Reset play time
         LDA #$01        ; Save file: 1st
         STA $0224       ; Set last viewed
         STZ $021F       ; Game's file: None
         STZ $0205       ; Set new game mode
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         LDA #$53        ; C3/1A64
         STA $26         ; Next: Fade-out
         RTS

; Reset play time
C32ABC:  TDC             ; Clear A
         TAY             ; Clear Y
         STY $021B       ; Zero hours, mins
         STY $021D       ; Zero secs, frames
         RTS

; 23: Sustain load confirmation
C32AC5:  JSR C31643      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BNE C32AF3      ; Abort if so
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32AFF      ; Exit if not
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; Chose "No"?
         BNE C32AF6      ; Abort if so
         LDY $1863       ; File's hrs, mins
         STY $021B       ; Set as current
         LDA $1865       ; File's seconds
         STA $021D       ; Set as current
         LDA $66         ; Loaded file
         STA $021F       ; Link to game
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Chose "No"
C32AF3:  JSR C30F14      ; Sound: Cursor
C32AF6:  JSR C3192A      ; Restore SRAM
         LDA #$20        ; C3/1D69
         STA $27         ; Queue Load menu
         STZ $26         ; Next: Fade-out
C32AFF:  RTS

; 3A: Initialize spell usage menu
C32B00:  LDA #$40        ; No cursor memory
         TSB $45         ; Set menu flag
         JSR C32B11      ; Init variables
         JSR C35E71      ; Draw menu
         JSR C30833      ; Queue cursor OAM
         LDA #$3B        ; Queue: Sustain menu
         BRA C32B40      ; Next: Fade-in

; Initialize variables for spell or item usage menu
C32B11:  JSR C335F7      ; Reset/Stop stuff
         LDA #$01        ; CGRAM: Refresh
         TSB $45         ; Set NMI flag
         LDA #$04        ; Channel: 2
         TSB $43         ; Queue Win1 HDMA
         STZ $1B         ; Null VRAM ptr LB
         STZ $1C         ; Null VRAM ptr HB
         JSR C37076      ; Reset BGs' X/Y
         JSR C31C0E      ; Load portraits
         LDA #$03        ; 64x64 at $0000
         STA $2107       ; Set BG1 map loc
         LDA #$C0        ; Channels: 6, 7
         TRB $43         ; Halt HDMA 6+7
         LDY #$0002      ; Y: 2
         STY $37         ; Set BG1 Y-Pos
         JSR C33033      ; Preload nav data
         LDA #$00        ; Min slot: 0
         LDY #C3305B     ; C3/305B
         JSR C311DE      ; Queue D-Pad fn
         RTS

; Set queued menu command, trigger fade-in
C32B40:  STA $27         ; Set queued cmd
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 3B: Handle single-target spell
C32B49:  LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BNE C32B61      ; Branch if so
         LDA $08         ; ...
         BIT #$20        ; Pushing L?
         BNE C32B61      ; Branch if so
         LDA $09         ; No-autofire keys
         BIT #$01        ; Pushing right?
         BNE C32B61      ; Branch if so
         LDA $09         ; ...
         BIT #$02        ; Pushing left?
         BEQ C32B8E      ; Branch if not
C32B61:  JSR C30F0E      ; Sound: Cursor
         JSR C32DAE      ; Spell
         JSR C357C4      ; Compute index
         REP #$21        ; 16-bit A; C-
         LDA $2134       ; Load index
         ADC #$0000      ; Add 0...
         TAX             ; Index it
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $C46AC0,X   ; Spell properties
         AND #$20        ; Can multi-target?
         BEQ C32B8E      ; Branch if not
         LDA $4E         ; Cursor row
         STA $5F         ; Save for revert
         LDA #$06        ; Main cursor: Off
         TRB $46         ; Set menu flag
         JSR C30924      ; Create blinkers
         LDA #$3D        ; C3/2E13
         STA $26         ; Next: Target all
         RTS

; Fork: Handle A
C32B8E:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32B97      ; Branch if not
         JMP C32BA7      ; Handle spell

; Fork: Handle B
C32B97:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32BA6      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA #$3C        ; C3/2DB7
         STA $27         ; Queue Magic menu
         STZ $26         ; Next: Fade-out
C32BA6:  RTS

; Handle spell usage on single target
C32BA7:  STZ $9C         ; Halve HP gain: N
         JSR C32D67      ; Get LV, Mag.Pwr
         JSR C32DA6      ; Target's address
         JSR C32CAF      ; Valid target?
         BCC C32BCD      ; Fail if not
         JSR C32D85      ; Lower caster's MP
         JSR C30F50      ; Play heal sound
         JSR C32DA6      ; Target's address
         LDA $0014,Y     ; Status LB
         STA $F8         ; Set as target's
         LDA $0015,Y     ; Status HB
         STA $FB         ; Set as target's
         JSR C32BD4      ; Adjust HP, status
         JMP C32C79      ; Redo GFX, test MP

; Fork: Invalid target
C32BCD:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Adjust spell target's HP and status
C32BD4:  LDA $000B,Y     ; Max HP LB
         STA $11B2       ; Set target's
         LDA $000C,Y     ; Max HP HB
         STA $11B3       ; Set target's
         PHY             ; Save index
         JSR C32DAE      ; Spell number
         LDX $00         ; Mode: Magic
         JSL $C20009     ; Get gain/status
         PLY             ; Actor's address
         LDA $9C         ; One target?
         BEQ C32BF7      ; Branch if so
         REP #$21        ; 16-bit A; C-
         LDA $11B0       ; HP gain
         LSR A           ; Halve it
         BRA C32BFC      ; Skip 2 lines
C32BF7:  REP #$21        ; 16-bit A; C-
         LDA $11B0       ; HP gain
C32BFC:  ADC $0009,Y     ; Add actor HP
         STA $0009,Y     ; Set actor HP
         SEP #$20        ; 8-bit A
         JSR C32C35      ; Enforce max
         LDA $FC         ; Status LB
         STA $0014,Y     ; Set actor's
         LDA $FF         ; Status HB
         STA $0015,Y     ; Set actor's
         LDA $9C         ; One target?
         BNE C32C34      ; Exit if not
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $69,X       ; Actor's address
         JSL $C20006     ; Get gear data
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         STY $67         ; Memorize it
         LDA $11D2       ; Immunities
         JSR C39995      ; Deny ailments
         LDA $11D4       ; Auto status
         JMP C399A4      ; Handle Float
C32C34:  RTS

; Keep HP from exceeding max HP, clear Carry if lower
C32C35:  LDA $000B,Y     ; Max HP LB
         STA $F3         ; Memorize it
         LDA $000C,Y     ; Max HP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30DFD      ; Cap at 9999
         REP #$20        ; 16-bit A
         LDA $0009,Y     ; Current HP
         CMP $F3         ; Under max?
         BCC C32C54      ; Exit if so
         LDA $F3         ; Max HP
         STA $0009,Y     ; Set HP
         SEC             ; ...
C32C54:  SEP #$20        ; 8-bit A
         RTS

; Keep MP from exceeding max MP, clear Carry if lower
C32C57:  LDA $000F,Y     ; Max MP LB
         STA $F3         ; Memorize it
         LDA $0010,Y     ; Max MP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30E0A      ; Cap at 999
         REP #$20        ; 16-bit A
         LDA $000D,Y     ; Current MP
         CMP $F3         ; Under max?
         BCC C32C76      ; Exit if so
         LDA $F3         ; Max MP
         STA $000D,Y     ; Set MP
         SEC             ; ...
C32C76:  SEP #$20        ; 8-bit A
         RTS

; Redraw party after spell usage, exit menu if short on MP
C32C79:  JSR C32C9C      ; Redraw party
         JSR C32D7A      ; Check caster gear
         JSR C32D9E      ; Caster's address
         JSR C32DAE      ; Spell used
         JSR C357DC      ; Define cost
         STX $E7         ; Memorize it
         LDX $000D,Y     ; Caster's MP
         CPX $E7         ; Can recast?
         BCS C32C9B      ; Exit if so
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         LDA #$3C        ; C3/2DB7
         STA $27         ; Queue Magic menu
         STZ $26         ; Next: Fade-out
C32C9B:  RTS

; Redraw party after spell or item usage
C32C9C:  LDA $4B         ; Cursor slot, 0 if MT
         STA $9C         ; Set portrait slot
         JSR C32561      ; Clear icons/portraits
         JSR C371A9      ; Clear names, stats
         JSR C3322E      ; Redo stats/icons/faces
         JSR C3739D      ; Load portrait colors
         JMP C37653      ; Queue portrait upload

; Establish whether spell target is valid
C32CAF:  LDA $0014,Y     ; Status
         AND #$80        ; Wound?
         BNE C32CDB      ; Branch if so
         JSR C32DAE      ; Spell
         CMP #$2D        ; Cure?
         BEQ C32D11      ; Branch if so
         CMP #$2E        ; Cure 2?
         BEQ C32D11      ; Branch if so
         CMP #$2F        ; Cure 3?
         BEQ C32D11      ; Branch if so
         CMP #$32        ; Antdot?
         BEQ C32D08      ; Branch if so
         CMP #$33        ; Remedy?
         BEQ C32CFF      ; Branch if so
         CMP #$22        ; Float?
         BEQ C32CE8      ; Branch if so
         CMP #$23        ; Imp?
         BEQ C32D1F      ; Succeed if so
         CMP #$2C        ; Dispel?
         BEQ C32CF1      ; Branch if so
         BRA C32D1D      ; Make spell fail

; Fork: Wound
C32CDB:  JSR C32DAE      ; Spell
         CMP #$30        ; Life?
         BEQ C32D1F      ; Succeed if so
         CMP #$31        ; Life 2?
         BEQ C32D1F      ; Succeed if so
         BRA C32D1D      ; Make spell fail

; Fork: Float
C32CE8:  LDA $0015,Y     ; Status
         AND #$80        ; Float?
         BNE C32D1D      ; Fail if so
         BRA C32D1F      ; Make spell work

; Fork: Dispel
C32CF1:  LDA $0014,Y     ; Status LB
         AND #$7F        ; Ignore Wound...
         ORA $0015,Y     ; Add high byte
         AND #$90        ; Clear or Float?
         BEQ C32D1D      ; Fail if neither
         BRA C32D1F      ; Make spell work

; Fork: Remedy
C32CFF:  LDA $0014,Y     ; Dark? Poison?
         AND #$45        ; Or Petrify?
         BEQ C32D1D      ; Fail if none
         BRA C32D1F      ; Make spell work

; Fork: Antdot
C32D08:  LDA $0014,Y     ; Status
         AND #$04        ; Poison?
         BEQ C32D1D      ; Fail if not
         BRA C32D1F      ; Make spell work

; Fork: Cure spells
C32D11:  LDA $0014,Y     ; Zombie? KO?
         AND #$C2        ; Or Petrify?
         BNE C32D1D      ; Fail if any
         JSR C32C35      ; At full HP?
         BCC C32D1F      ; Succeed if not
C32D1D:  CLC             ; Make spell fail
         RTS             ; Exit
C32D1F:  SEC             ; Make spell work
         RTS

; Handle spell usage on party
C32D21:  STZ $AF         ; Valid target: N
         LDA #$01        ; Half gain, etc.
         STA $9C         ; Set heal mode
         JSR C32D67      ; Get LV, Mag.Pwr
         TDC             ; Member: 1st
C32D2B:  PHA             ; Save member
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         BEQ C32D53      ; Skip if nobody
         JSR C32CAF      ; Valid target?
         BCC C32D53      ; Skip if not
         LDA $0014,Y     ; Status LB
         STA $F8         ; Set target's
         LDA $0015,Y     ; Status HB
         STA $FB         ; Set target's
         JSR C32BD4      ; Adjust HP, status
         JSR C32D67      ; Get LV, Mag.Pwr
         LDA $AF         ; 1st valid target?
         BNE C32D53      ; Branch if not
         JSR C30F50      ; Play heal sound
         JSR C32D85      ; Lower caster's MP
         INC $AF         ; Valid target: Y
C32D53:  TDC             ; Clear A
         PLA             ; Member slot
         INC A           ; Member slot +1
         CMP #$04        ; Done all 4?
         BNE C32D2B      ; Loop if not
         LDA $AF         ; Is any valid?
         BNE C32D64      ; Branch if so
         JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
C32D64:  JMP C32C79      ; Redo GFX, test MP

; Load caster's Mag.Pwr and level (for C2/0009)
C32D67:  JSR C32D7A      ; Define stats
         LDA $11A0       ; Mag.Pwr
         STA $11AE       ; Memorize it
         JSR C32D9E      ; Actor's address
         LDA $0008,Y     ; Level
         STA $11AF       ; Memorize it
         RTS

; Load member's stats and properties with gear
C32D7A:  TDC             ; Clear A
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $69,X       ; Actor
         JSL $C20006     ; Load data
         RTS

; Decrease caster's MP
C32D85:  JSR C32DAE      ; Spell
         JSR C357DC      ; Define cost
         STX $E7         ; Memorize it
         JSR C32D9E      ; Define Y
         REP #$20        ; 16-bit A
         LDA $000D,Y     ; Actor's MP
         SEC             ; Prepare SBC
         SBC $E7         ; Subtract cost
         STA $000D,Y     ; Save changes
         SEP #$20        ; 8-bit A
         RTS

; Get caster's SRAM block address
C32D9E:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; SRAM address
         RTS

; Get target's SRAM block address
C32DA6:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; SRAM address
         RTS

; Get selected spell
C32DAE:  TDC             ; Clear A
         LDA $99         ; Spell slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Spell
         RTS

; 3C: Return to Magic menu
C32DB7:  JSR C335F7      ; Reset/Stop stuff
         JSR C3719C      ; Set Win1 bounds
         LDA #$42        ; Allow back row
         TRB $45         ; And cursor memory
         STZ $4A         ; List scroll: 0
         STZ $49         ; Top BG1 WR row: 1
         JSR C35482      ; Set to shift text
         JSR C3533D      ; Draw menu, etc.
         JSR C30833      ; Queue cursor OAM
         JSR C32190      ; Create scrollbar
         JSR C35245      ; Load navig data
         LDA $8E         ; Old cursor column
         STA $4D         ; Set onscreen col
         LDY $8E         ; Old cursor loc
         STY $4F         ; Set as current
         LDA $90         ; Old scroll pos
         STA $4A         ; Set as current
         LDA $4A         ; ...
         STA $E0         ; Memorize it...
         LDA $50         ; List row
         SEC             ; Prepare SBC
         SBC $E0         ; Sub scroll pos
         STA $4E         ; Set cursor row
         JSR C3524E      ; Relocate cursor
         JSR C321B8      ; Draw spells, etc.
         JSR C35895      ; Draw MP cost
         JSR C30ED9      ; Upload BG3 A+B
         JSR C313D3      ; Refresh screen
         LDY $00         ; X: 0
         STY $35         ; Set BG1 X-Pos
         JSR C31BFF      ; Queue desc anim
         LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         JSR C30F68      ; Queue lists upload
         LDA #$1A        ; C3/2855
         STA $27         ; Queue Magic menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 3D: Handle multitarget spell
C32E13:  LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BNE C32E2B      ; Branch if so
         LDA $08         ; ...
         BIT #$20        ; Pushing L?
         BNE C32E2B      ; Branch if so
         LDA $09         ; No-autofire keys
         BIT #$01        ; Pushing right?
         BNE C32E2B      ; Branch if so
         LDA $09         ; ...
         BIT #$02        ; Pushing left?
         BEQ C32E36      ; Branch if not
C32E2B:  JSR C30F0E      ; Sound: Cursor
         JSR C32E52      ; Swap cursors
         LDA #$3B        ; C3/2B49
         STA $26         ; Next: One target
         RTS

; Fork: Handle A
C32E36:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C32E3F      ; Branch if not
         JMP C32D21      ; Handle spell

; Fork: Handle B
C32E3F:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C32E51      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         JSR C32E52      ; Swap cursors
         LDA #$3C        ; C3/2DB7
         STA $27         ; Queue Magic menu
         STZ $26         ; Next: Fade-out
C32E51:  RTS

; Revert to a single target for spell
C32E52:  JSR C33033      ; Preload nav data
         JSR C30833      ; Queue cursor OAM
         LDA #$00        ; Min slot: 0
         LDY #C3305B     ; C3/305B
         JSR C311DE      ; Queue D-Pad fn
         JSR C3121B      ; Run anim queue
         LDA $5F         ; Old cursor row
         STA $4E         ; Set as current
         LDA #$08        ; Blinkers: Off
         TRB $46         ; Set menu flag
         RTS

; Swap actor info for switched members
C32E6C:  TDC             ; Clear A
         LDA $28         ; Chosen slot A
         TAX             ; Index it
         LDA $4B         ; Chosen slot B
         TAY             ; Index it
         LDA $75,X       ; A's party info
         STA $E0         ; Memorize it
         LDA $0075,Y     ; B's party info
         STA $75,X       ; Set as A's
         LDA $E0         ; A's party info
         STA $0075,Y     ; Set as B's
         LDA $69,X       ; A's actor ID
         STA $E0         ; Memorize it
         LDA $0069,Y     ; B's actor ID
         STA $69,X       ; Set as A's
         LDA $E0         ; A's actor ID
         STA $0069,Y     ; Set as B's
         TDC             ; Clear A
         LDA $28         ; Chosen slot A
         ASL A           ; Double it
         TAX             ; Index it
         LDA $4B         ; Chosen slot B
         ASL A           ; Double it
         TAY             ; Index it
         REP #$20        ; 16-bit A
         LDA $6D,X       ; A's data adr
         STA $E7         ; Memorize it
         LDA $006D,Y     ; B's data adr
         STA $6D,X       ; Set as A's
         LDA $E7         ; A's data adr
         STA $006D,Y     ; Set as B's
         SEP #$20        ; 8-bit A
         RTS

; Toggle member's row, set to shift portrait
C32EAB:  TDC             ; Clear A
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $75,X       ; Party info
         STA $E0         ; Memorize it
         LDA $60,X       ; Queue index
         TAX             ; Index it
         LDA $E0         ; Party info
         BIT #$20        ; Front row?
         BEQ C32EC4      ; Branch if so
         LDA #$20        ; Row: Front
         TRB $E0         ; Add to info
         LDA #$03        ; Shift: Right
         BRA C32ECA      ; Skip 3 lines
C32EC4:  LDA #$20        ; Row: Back
         TSB $E0         ; Add to info
         LDA #$02        ; Shift: Left
C32ECA:  STA $7E3649,X   ; Set anim mode
         TDC             ; ...
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $E0         ; Party info
         STA $75,X       ; Set member's
         RTS

; Set to delete all portraits
C32ED7:  TDC             ; Clear A
         LDA $60         ; Queue index A
         TAX             ; Index it
         LDA #$FF        ; Null value
         STA $7E35C9,X   ; Face A: Off
         LDA $61         ; Queue index B
         TAX             ; Index it
         LDA #$FF        ; Null value
         STA $7E35C9,X   ; Face B: Off
         LDA $62         ; Queue index C
         TAX             ; Index it
         LDA #$FF        ; Null value
         STA $7E35C9,X   ; Face C: Off
         LDA $63         ; Queue index D
         TAX             ; Index it
         LDA #$FF        ; Null value
         STA $7E35C9,X   ; Face D: Off
         RTS

; Handle selection in main menu list
C32EFD:  TDC             ; Clear A
         LDA $4B         ; Chosen menu
         STA $25         ; Set submenu
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C32F07,X)  ; Handle choice

; Jump table for the above
C32F07:  dw C32F21       ; Item
         dw C32F2B       ; Skills
         dw C32F2B       ; Equip
         dw C32F2B       ; Relic
         dw C32F2B       ; Status
         dw C32F15       ; Config
         dw C32F45       ; Save

; Invoke Config menu
C32F15:  JSR C30F1D      ; Sound: Click
         STZ $5F         ; Cursor: Bat.Mode
         STZ $26         ; Next: Fade-out
         LDA #$0D        ; C3/1CE3
         STA $27         ; Queue Config
         RTS

; Invoke Item menu
C32F21:  JSR C30F1D      ; Sound: Click
         STZ $26         ; Next: Fade-out
         LDA #$07        ; C3/1B3C
         STA $27         ; Queue Item menu
         RTS

; Initialize portrait targeting with main menu command
C32F2B:  JSR C30F1D      ; Sound: Click
         LDA #$02        ; List cursor: Off
         TRB $46         ; Set menu flag
         JSR C33033      ; Preload nav data
         LDA #$00        ; Min slot: 0
         LDY #C3305B     ; C3/305B
         JSR C311DE      ; Queue D-Pad fn
         JSR C32FA1      ; Create blinker
         LDA #$06        ; C3/1E4E
         STA $26         ; Next: Targeting
         RTS

; Invoke Save menu if allowed
C32F45:  LDA $0201       ; Can save here?
         BPL C32F5A      ; Fail if not
         JSR C30F1D      ; Sound: Click
         STZ $26         ; Next: Fade-out
         LDA #$13        ; C3/1D06
         STA $27         ; Queue Save menu
         STA $9E         ; Set root menu cmd
         LDA #$04        ; C3/1AF0
         STA $9F         ; Set main menu cmd
         RTS             ; Exit
C32F5A:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Initiate shifting to Order menu
C32F61:  LDA #$02        ; List cursor: Off
         TRB $46         ; Set menu flag
         JSR C33033      ; Preload nav data
         LDA #$00        ; Min slot: 0
         LDY #C3305B     ; C3/305B
         JSR C311DE      ; Queue D-Pad fn
         LDA #$06        ; Frames: 6
         STA $20         ; Set scroll timer
         LDY #$FFF4      ; Speed: -12
         STY $9C         ; Set scroll speed
         LDA #$05        ; Blinker: Off
         TRB $46         ; Order cursor: Off
         LDA #$0F        ; C3/247F
         STA $27         ; Queue: Choice 1
         LDA #$65        ; C3/37AF
         STA $26         ; Next: Pan screen
         RTS

; Create blinking cursor for Espers menu
C32F86:  LDA #$02        ; Min slot: 16
         LDY #C30956     ; C3/0956
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA #$0038      ; X: 56
         STA $7E33CA,X   ; Set sprite's
         LDA #$0036      ; Y: 54
         STA $7E344A,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Create blinking cursor to the right of main cursor
C32FA1:  LDA #$02        ; Min slot: 16
         LDY #C30882     ; C3/0882
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA $55         ; Cursor's X
         INC A           ; +1 px right
         INC A           ; +1 px right
         STA $7E33CA,X   ; Set blinker X
         LDA $57         ; Cursor's Y
         STA $7E344A,X   ; Set blinker Y
         SEP #$20        ; 8-bit A
         RTS

; Create blinking cursor to northeast of main cursor
C32FBC:  LDA #$01        ; Min slot: 8
         LDY #C30882     ; C3/0882
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA $55         ; Cursor's X
         CLC             ; Prepare ADC
         ADC #$0004      ; +4 px right
         STA $7E33CA,X   ; Set blinker X
         LDA $57         ; Cursor's Y
         SEC             ; Prepare SBC
         SBC #$0004      ; +4 px up
         STA $7E344A,X   ; Set blinker Y
         SEP #$20        ; 8-bit A
         RTS

; Update cursor position in main menu list
C32FDD:  TAX             ; Index mode
         JMP (C32FE1,X)  ; Handle mode

; Jump table for the above
C32FE1:  dw C32FE5       ; Initialize data
         dw C33006       ; Update position

; Mode 0: Initialize data
C32FE5:  LDX $2D         ; Queue index
         LDA #$02        ; Show cursor: Y
         TSB $46         ; Set menu flag
         INC $3649,X     ; Mode +1
         LDY #C33020     ; C3/3020
         JSR C30681      ; Load navig data
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C33000      ; Branch if not
         LDY $022B       ; Former position
         STY $4D         ; Set as current
C33000:  LDY #C33025     ; C3/3025
         JSR C306C3      ; Set cursor X/Y

; Mode 1: Update position
C33006:  LDA $46         ; Menu flags
         BIT #$02        ; Delete cursor?
         BEQ C3301E      ; Dequeue if so
         LDX $2D         ; Queue index
         JSR C307B0      ; Handle D-Pad
         LDY #C33025     ; C3/3025
         JSR C306C3      ; Set cursor X/Y
         LDY $4D         ; Cursor position
         STY $022B       ; To cursor memory
         SEC             ; Set to requeue
         RTS             ; Exit
C3301E:  CLC             ; Set to dequeue
         RTS

; Navigation data for main menu
C33020:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $07          ; 7 rows

; Cursor positions for main menu			=== SNES: Shifted leftward (all)
C33025:  dw $12B7        ; Item
         dw $21B7        ; Skills
         dw $30B7        ; Equip
         dw $3FB7        ; Relic
         dw $4EB7        ; Status
         dw $5DB7        ; Config
         dw $6CB7        ; Save

; Preload nav data for portrait selection, disable empty slots
C33033:  JSR C3304C      ; Load navig data
         TDC             ; Clear A
         TAX             ; 1st: Member 1
         TAY             ; ...
C33039:  LDA $0069,X     ; Actor in slot
         BPL C33045      ; Skip if any
         PHX             ; Save slot
         TXA             ; Move it to A
         ASL A           ; Double it
         TAX             ; Reindex it
         STZ $85,X       ; Disable slot
         PLX             ; Member slot
C33045:  INX             ; Member slot +1
         CPX #$0004      ; Done all 4?
         BNE C33039      ; Loop if not
         RTS

; Preload navigation data for portrait selection
C3304C:  LDX $00         ; Index: 0
C3304E:  LDA.L C330DD,X  ; Navig data
         STA $80,X       ; Save in RAM
         INX             ; Index +1
         CPX #$000D      ; At C3/30EA?
         BNE C3304E      ; Loop if not
         RTS

; Update movable cursor's position for portrait selection
C3305B:  TAX             ; Index mode
         JMP (C3305F,X)  ; Handle mode

; Jump table for the above
C3305F:  dw C33063       ; Initialize data
         dw C330AF       ; Update position

; Mode 0: Initialize data
C33063:  LDX $2D         ; Queue index
         LDA #$14        ; Main cursor: On
         TSB $46         ; Enable D-Pad
         INC $3649,X     ; Mode +1
         JSR C33090      ; Load navig data
         LDA $45         ; Menu flags
         BIT #$40        ; Skip cursor mem?
         BNE C33081      ; Branch if so
         LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C33081      ; Branch if not
         LDY $022D       ; Former position
         STY $4D         ; Set as current
C33081:  JSR C330A3      ; Relocate cursor
         LDA $55         ; On empty slot?
         BNE C3308E      ; Exit if not
         JSR C33090      ; Target leader
         JSR C330A3      ; Relocate cursor
C3308E:  SEC             ; Set to requeue
         RTS

; Load custom nav data for portrait selection, target leader
C33090:  LDY #$0080      ; ...
         JSR C30681      ; ...
         LDY #$0080      ; 00/0080
         LDA #$00        ; Bank: 00
         STA $ED         ; Set source HB
         JSR C30685      ; Load navig data
         JMP C306A1      ; Target leader

; Set portrait cursor's slot and base pixel position
C330A3:  LDY #$0085      ; 00/0085
         STY $E7         ; Set src LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         JMP C306C6      ; Relocate cursor

; Mode 1: Update position
C330AF:  LDA $45         ; Menu flags
         BIT #$40        ; Skip cursor mem?
         BNE C330BA      ; Branch if so
         LDY $4D         ; Cursor position
         STY $022D       ; To cursor memory
C330BA:  LDA $46         ; Menu flags
         BIT #$04        ; Delete cursor?
         BEQ C330DB      ; Dequeue if so
         BIT #$10        ; Swapping chars?
         BEQ C330D9      ; Exit if so
         LDX $2D         ; Queue index
C330C6:  JSR C307B0      ; Handle D-Pad
         LDY #$0085      ; 00/0085
         STY $E7         ; Set src LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         JSR C306C6      ; Relocate cursor
         LDA $55         ; On empty slot?
         BEQ C330C6      ; Retarget if so
C330D9:  SEC             ; Set to requeue
         RTS             ; Exit
C330DB:  CLC             ; Set to dequeue
         RTS

; Navigation data for portrait selection
C330DD:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $04          ; 4 rows

; Cursor positions for portrait selection
C330E2:  dw $2808        ; Member 1
         dw $5808        ; Member 2
         dw $8808        ; Member 3
         dw $B808        ; Member 4

; Queue menu fade-out
C330EA:  TDC             ; Min slot: 0
         LDY #C3313A     ; C3/313A
         JMP C311DE      ; Put in queue

; Queue menu fade-in
C330F1:  TDC             ; Min slot: 0
         LDY #C33165     ; C3/3165
         JMP C311DE      ; Put in queue

; Queue mosaic effect
C330F8:  TDC             ; Min slot: 0
         LDY #C330FF     ; C3/30FF
         JMP C311DE      ; Put in queue

; Process queued mosaic effect
C330FF:  TAX             ; Index mode
         JMP (C33103,X)  ; Handle mode

; Jump table for the above
C33103:  dw C33107       ; Initialize mosaic
         dw C33114       ; Sustain mosaic

; Mode 0: Initialize mosaic
C33107:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         STZ $33CA,X     ; 1st: C3/3132
         LDA #$08        ; Frames: 8
         STA $3349,X     ; Set timer

; Mode 1: Sustain mosaic
C33114:  LDX $2D         ; Queue index
         LDA $3349,X     ; Timer expired?
         BEQ C33130      ; Dequeue if so
         TDC             ; ...
         LDA $33CA,X     ; Table index
         TAX             ; Index it
         LDA.L C33132,X  ; Parameters
         STA $B5         ; Save in RAM
         LDX $2D         ; Queue index
         INC $33CA,X     ; Table index +1
         DEC $3349,X     ; Timer -1
         SEC             ; Set to requeue
         RTS             ; Exit
C33130:  CLC             ; Set to dequeue
         RTS

; Mosaic parameters
C33132:  db $17          ; Intensity 1 for BG1-BG3
         db $27          ; Intensity 2 for BG1-BG3
         db $37          ; Intensity 3 for BG1-BG3
         db $47          ; Intensity 4 for BG1-BG3
         db $37          ; Intensity 3 for BG1-BG3
         db $27          ; Intensity 2 for BG1-BG3
         db $17          ; Intensity 1 for BG1-BG3
         db $07          ; Intensity 0 for BG1-BG3

; Process queued menu fade-out
C3313A:  TAX             ; Index mode
         JMP (C3313E,X)  ; Handle mode

; Jump table for the above
C3313E:  dw C33142       ; Initialize brightness
         dw C3314C       ; Decrease brightness

; Mode 0: Initialize brightness
C33142:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$0F        ; BRT: 15 and ON
         STA $33CA,X     ; Set next BRT

; Mode 1: Decrease brightness
C3314C:  LDY $20         ; Timer expired?
         BEQ C3315F      ; Finalize if so
         LDX $2D         ; Queue index
         LDA $33CA,X     ; Next brightness
         STA $44         ; Set as current
         DEC $33CA,X     ; Next BRT -1
         DEC $33CA,X     ; Next BRT -1
         SEC             ; Set to requeue
         RTS             ; Exit
C3315F:  LDA #$01        ; BRT: 1 and ON
         STA $44         ; Set brightness
         CLC             ; Set to dequeue
         RTS

; Process queued menu fade-in
C33165:  TAX             ; Index mode
         JMP (C33169,X)  ; Handle mode

; Jump table for the above
C33169:  dw C3316D       ; Initialize brightness
         dw C33177       ; Increase brightness

; Mode 0: Initialize brightness
C3316D:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$01        ; BRT: 1 and ON
         STA $344A,X     ; Set next BRT

; Mode 1: Increase brightness
C33177:  LDY $20         ; Timer expired?
         BEQ C3318A      ; Finalize if so
         LDX $2D         ; Queue index
         LDA $344A,X     ; Next brightness
         STA $44         ; Set as current
         INC $344A,X     ; Next BRT +1
         INC $344A,X     ; Next BRT +1
         SEC             ; Set to requeue
         RTS             ; Exit
C3318A:  LDA #$0F        ; BRT: 15 and ON
         STA $44         ; Set brightness
         CLC             ; Set to dequeue
         RTS

; Draw and upload main menu
C33190:  JSR C340B9      ; Apply user font
         JSR C371BC      ; Clear BG2 map A
         JSR C371C1      ; Clear BG2 map B
         JSR C371AD      ; Clear BG1 map B
         JSR C371D5      ; Clear BG3 map B
         LDY #C3326A     ; C3/326A
         JSR C303C4      ; Draw Order box A
         LDY #C3326E     ; C3/326E
         JSR C303C4      ; Draw Order box B
         LDY #C33262     ; C3/3262
         JSR C303C4      ; Draw main window
         LDY #C33256     ; C3/3256
         JSR C303C4      ; Draw option box
         JSR C3320B      ; Draw stats, etc.
         JSR C33307      ; Draw time
         JSR C3328E      ; Draw menu list
         JMP C3323A      ; Upload text maps

; Draw and upload save confirmation menu
C331C3:  JSR C340B9      ; Apply user font
         JSR C37616      ; Load portraits
         JSR C3739D      ; And their colors
         JSR C33243      ; Upload skin
         LDY #C33262     ; C3/3262
         JSR C303C4      ; Draw main window
         LDY #C33266     ; C3/3266
         JSR C303C4      ; Draw Yes/No box
         JSR C3320B      ; Draw stats, etc.
         JSR C33330      ; Draw time
         JSR C33272      ; Draw question
         JMP C3323A      ; Upload text maps

; Draw and upload load confirmation menu
C331E7:  JSR C340B9      ; Apply user font
         JSR C37616      ; Load portraits
         JSR C3739D      ; And their colors
         JSR C33243      ; Upload skin
         LDY #C33262     ; C3/3262
         JSR C303C4      ; Draw main window
         LDY #C33266     ; C3/3266
         JSR C303C4      ; Draw Yes/No box
         JSR C3320B      ; Draw stats, etc.
         JSR C33330      ; Draw time
         JSR C33280      ; Draw question
         JMP C3323A      ; Upload text maps

; Draw elements shared by main menu and save file submenus
C3320B:  TDC             ; Gradient set: 0
         JSL $D4CA1D     ; Create gradient
         LDY #C3325A     ; C3/325A
         JSR C303C4      ; Draw time window
         LDY #C3325E     ; C3/325E
         JSR C303C4      ; Draw steps window
         JSR C30EBD      ; Upload windows
         JSR C33225      ; Draw party info
         JMP C332BC      ; Draw game stats

; Draw party info
C33225:  JSR C371A9      ; Clear BG1 map A
         JSR C371D0      ; Clear BG3 map A
         JSR C371DA      ; Clear BG3 map C
C3322E:  JSR C3338C      ; Handle member 1
         JSR C333D8      ; Handle member 2
         JSR C33424      ; Handle member 3
         JMP C33470      ; Handle member 4

; Upload text tilemaps for menu with portraits
C3323A:  JSR C30E93      ; Upload BG1 A+B
         JSR C30ED9      ; Upload BG3 A+B
         JMP C30EE7      ; Upload BG3 C+D

; Upload skin for viewed save file
C33243:  LDA $66         ; File viewed
         CMP #$01        ; File 1?
         BEQ C33250      ; Branch if so
         CMP #$02        ; File 2?
         BEQ C33253      ; Branch if so
         JMP C33BAD      ; Handle file 3
C33250:  JMP C33B75      ; Handle file 1
C33253:  JMP C33B91      ; Handle file 2

; Window layout for main menu and save file submenus
C33256:  dw $58B9,$0D05  ; 07x15 at $58B9 (Options)		=== SNES: Expanded lefward
C3325A:  dw $5C79,$0205  ; 07x04 at $5C79 (Time)		=== SNES: Expanded leftward
C3325E:  dw $5D75,$0507  ; 09x07 at $5D75 (Steps)
C33262:  dw $588B,$181C  ; 30x26 at $588B (Party)
C33266:  dw $58B5,$0A07  ; 09x12 at $58B5 (Yes/No)
C3326A:  dw $60B9,$0207  ; 09x04 at $60B9 (Order; L part)
C3326E:  dw $5885,$0201  ; 03x04 at $5885 (Order; R part)

; Draw confirmation text for Save menu
C33272:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C3382D     ; Text ptrs loc
         LDY #$000A      ; Strings: 5
         JSR C3714E      ; Draw text
         RTS

; Draw confirmation text for Load menu
C33280:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C33825     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3714E      ; Draw text
         RTS

; Draw list of submenus in main menu
C3328E:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C337F1     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3712C      ; Do Item..Status
         LDA #$20        ; ...
         STA $29         ; ...
         LDX #C33821     ; Text ptrs loc
         LDY #$0004      ; Strings: 2
         JSR C3714E      ; Do Equip/Config
         LDA $0201       ; Can save here?
         BPL C332B1      ; Branch if not
         LDA #$20        ; Color: User's
         BRA C332B3      ; Skip a line
C332B1:  LDA #$24        ; Color: Gray
C332B3:  STA $29         ; Set palette
         LDY #C338BF     ; Text pointer
         JSR C30326      ; Draw "Save"
         RTS

; Draw most text in small windows of main menu or save file submenu
C332BC:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C338CC     ; Text pointer
         JSR C302F9      ; Draw ":"
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C337EB     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw SE titles
         LDY #C338D6     ; Text pointer
         JSR C30326      ; Draw "Gp"
         JSR C33369      ; Cap GP
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY $1866       ; Steps LBs
         STY $F1         ; Memorize them
         LDA $1868       ; Steps HB
         STA $F3         ; Memorize it
         JSR C30605      ; Turn into text
         LDX #$7DF7      ; Text position
         JSR C3052F      ; Draw step count
         LDY $1860       ; Gold LBs
         STY $F1         ; Memorize them
         LDA $1862       ; Gold HB
         STA $F3         ; Memorize it
         JSR C30605      ; Turn into text
         LDX #$7EB7      ; Text position
         JSR C3052F      ; Draw GP total
         RTS

; Draw time in main menu
C33307:  LDA $1188       ; Timer 0 flags
         BIT #$10        ; Override clock?
         BEQ C33324      ; Branch if not
         LDY $1189       ; Countdown timer
         JSR C3334D      ; Divide by 60
         JSR C3334D      ; Divide by 60
         LDA $E7         ; Minutes
         STA $1863       ; Set shown hours
         LDA $4216       ; Seconds
         STA $1864       ; Set shown mins
         BRA C33330      ; Draw time

; Fork: Normal clock
C33324:  LDY $021B       ; Hours, mins
         STY $1863       ; Save in SRAM
         LDA $021D       ; Seconds
         STA $1865       ; Save in SRAM

; Fork: Draw time
C33330:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDA $1863       ; Shown hours
         JSR C30563      ; Turn into text
         LDX #$7CFB      ; Text position
         JSR C30539      ; Draw 2 digits
         LDA $1864       ; Shown minutes
         JSR C3057C      ; Turn into text
         LDX #$7D01      ; Text position
         JSR C30539      ; Draw 2 digits
         RTS

; Divide countdown timer's value by 60
C3334D:  STY $4204       ; Set dividend
         LDA #$3C        ; 60
         STA $4206       ; Set divisor
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         NOP
         LDY $4214       ; Quotient
         STY $E7         ; Memorize it
         RTS

; Enforce GP cap
C33369:  LDA #$7F        ; Cap LB
         CMP $1860       ; C- if < GP LB
         LDA #$96        ; Cap MB
         SBC $1861       ; Deduct GP w/ C
         LDA #$98        ; Cap HB
         SBC $1862       ; Deduct GP w/ C
         BCS C33385      ; Exit if < 10M
         LDY #$967F      ; Cap LBs
         STY $1860       ; Set gold LBs
         LDA #$98        ; Cap HB
         STA $1862       ; Set gold HB
C33385:  RTS

; Hi-fork: Hide portrait
C33386:  JSR C30A8D      ; Init portrait
         JMP C334B6      ; Hide portrait

; Draw info for member 1
C3338C:  LDA $69         ; Nobody here?
         BMI C33386      ; Abort if so
         LDX $6D         ; Actor's address
         STX $67         ; Memorize it
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C33809     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         LDY #$38E7      ; Class/KO pos			=== SNES: +40h as no diacritics
         LDX #$1578      ; Icon position
         STZ $48         ; Anim mode: 0
         JSR C334C2      ; Do class/status		=== SNES: No class
         LDX #C337F9     ; Text ptrs loc
         STX $F1         ; ...
         LDY #$0004      ; Strings: 2
         STY $EF         ; ...
         JSR C3712C      ; Draw both "/"
         LDY #$38D9      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDX #C333C8     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
         JMP C30A8D      ; Create portrait

; Tilemap pointers for stats of member 1
C333C8:  dw $39A7        ; Level
         dw $39E3        ; HP
         dw $39ED        ; Max HP
         dw $3A23        ; MP
         dw $3A2D        ; Max MP

; Hi-fork: Hide portrait
C333D2:  JSR C30AB6      ; Init portrait
         JMP C334B6      ; Hide portrait

; Draw info for member 2
C333D8:  LDA $6A         ; Nobody here?
         BMI C333D2      ; Abort if so
         LDX $6F         ; Actor's address
         STX $67         ; Memorize it
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C3380F     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         LDY #$3A67      ; Class/KO pos			=== SNES: +40h as no diacritics
         LDX #$4578      ; Icon position
         STZ $48         ; Anim mode: 0
         JSR C334C2      ; Do class/status		=== SNES: No class
         LDX #C337FD     ; Text ptrs loc
         STX $F1         ; ...
         LDY #$0004      ; Strings: 2
         STY $EF         ; ...
         JSR C3712C      ; Draw both "/"
         LDY #$3A59      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDX #C33414     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
         JMP C30AB6      ; Create portrait

; Tilemap pointers for stats of member 2
C33414:  dw $3B27        ; Level
         dw $3B63        ; HP
         dw $3B6D        ; Max HP
         dw $3BA3        ; MP
         dw $3BAD        ; Max MP

; Hi-fork: Hide portrait
C3341E:  JSR C30AE1      ; Init portrait
         JMP C334B6      ; Hide portrait

; Draw info for member 3
C33424:  LDA $6B         ; Nobody here?
         BMI C3341E      ; Abort if so
         LDX $71         ; Actor's address
         STX $67         ; Memorize it
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C33815     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         LDY #$3BE7      ; Class/KO pos			=== SNES: +40h as no diacritics
         LDX #$7578      ; Icon position
         STZ $48         ; Anim mode: 0
         JSR C334C2      ; Do class/status		=== SNES: No class
         LDX #C33801     ; Text ptrs loc
         STX $F1         ; ...
         LDY #$0004      ; Strings: 2
         STY $EF         ; ...
         JSR C3712C      ; Draw both "/"
         LDY #$3BD9      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDX #C33460     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
         JMP C30AE1      ; Create portrait

; Tilemap pointers for stats of member 3
C33460:  dw $3CA7        ; Level
         dw $3CE3        ; HP
         dw $3CED        ; Max HP
         dw $3D23        ; MP
         dw $3D2D        ; Max MP

; Hi-fork: Hide portrait
C3346A:  JSR C30B0C      ; Init portrait
         JMP C334B6      ; Hide portrait

; Draw info for member 4
C33470:  LDA $6C         ; Nobody here?
         BMI C3346A      ; Abort if so
         LDX $73         ; Actor's address
         STX $67         ; Memorize it
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C3381B     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         LDY #$3D67      ; Class/KO pos			=== SNES: +40h as no diacritics
         LDX #$A578      ; Icon position
         STZ $48         ; Anim mode: 0
         JSR C334C2      ; Do class/status		=== SNES: No class
         LDX #C33805     ; Text ptrs loc
         STX $F1         ; ...
         LDY #$0004      ; Strings: 2
         STY $EF         ; ...
         JSR C3712C      ; Draw both "/"
         LDY #$3D59      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDX #C334AC     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
         JMP C30B0C      ; Create portrait

; Tilemap pointers for stats of member 4
C334AC:  dw $3E27        ; Level
         dw $3E63        ; HP
         dw $3E6D        ; Max HP
         dw $3EA3        ; MP
         dw $3EAD        ; Max MP

; Hide portrait for vacant member slot
C334B6:  REP #$20        ; 16-bit A
         LDA #$00D8      ; Base Y: 216
         STA $7E344A,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Display actor's status or class (excludes Status menu)	=== SNES: No class
C334C2:  STX $E7         ; Save icon pos
         JSR C335E1      ; Set text pos
         LDA $0014,Y     ; Wounded?
         BMI C3354B      ; Draw it if so
         AND #$70        ; Clear/Imp/Pet
         STA $E1         ; Memorize them
         LDA $0014,Y     ; Status LB
         AND #$07        ; Dark/Zom/Poison
         ASL A           ; Put in bits 1-3
         STA $E2         ; Memorize them
         LDA $0015,Y     ; Status HB
         AND #$80        ; Isolate Float
         ORA $E1         ; Add Clear, etc.
         ORA $E2         ; Add Dark, etc.
         STA $E1         ; ...
         BEQ C33544      ; Use class if none		=== SNES: No class
         STZ $F1         ; Sprite index LB
         STZ $F2         ; Sprite index HB
         LDX #$0007      ; Status left: 7
C334EC:  PHX             ; Save counter
         ASL A           ; Got current?
         BCC C33537      ; Skip if not
         PHA             ; Save status
         LDA #$03        ; Min slot: 24
         LDY #C382C9     ; C3/82C9
         JSR C311DE      ; Queue icon OAM
         LDA #$01        ; Pans with BG1
         STA $7E364A,X   ; Set OBJ flags
         LDA $48         ; Anim mode
         STA $7E3649,X   ; Set icon's
         TXY             ; Queue index
         LDX $F1         ; Sprite index
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $D8ECAF,X   ; Anim table ptr		=== SNES: $D8EC25,X
         STA $32C9,Y     ; Set icon's
         SEP #$20        ; 8-bit A
         LDA $E7         ; X position
         STA $33CA,Y     ; Set icon's
         LDA $E8         ; Y position
         STA $344A,Y     ; Set icon's
         TDC             ; Clear A
         STA $33CB,Y     ; No use...
         STA $344B,Y     ; No use...
         LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set ptr HB
         PLB             ; Restore DB
         CLC             ; Prepare ADC
         LDA #$0A        ; Modifier: 10
         ADC $E7         ; Add current X
         STA $E7         ; Set current X
         PLA             ; Statuses
C33537:  INC $F1         ; Sprite index +1
         INC $F1         ; Sprite index +1
         PLX             ; Statuses left
         DEX             ; One less left
         BNE C334EC      ; Loop till last
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         RTS             ; ^ For stats

; Fork: Draw actor class
C33544:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JMP C33583      ; Draw class			=== SNES: No class

; Fork: Draw "Wounded"
C3354B:  LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Index: 0
C33553:  LDA.L C337E3,X  ; Letter
         STA $2180       ; Add to string
         INX             ; Point to next
         CPX #$0008      ; Copied 8?
         BNE C33553      ; Loop if not
         STZ $2180       ; End string
         LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         JMP C387B9      ; Draw string

; Draw actor name
C3356A:  JSR C335E1      ; Set pos/WRAM/Y
C3356D:  LDX #$0006      ; Letters: 6
C33570:  LDA $0002,Y     ; Letter
         STA $2180       ; Add to string
         INY             ; Point to next
         DEX             ; One less left
         BNE C33570      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Draw actor class					%%%
C33580:  JSR C335E1      ; Set pos/WRAM/Y
C33583:  LDA $0000,Y     ; Actor
         STA $4202       ; Set multiplicand
         LDA #$07        ; String size
         STA $4203       ; Set multiplier
         NOP
         NOP
         NOP
         NOP
         LDX $4216       ; Index product
         LDY #$0007      ; Letters: 7
C33598:  LDA $CF3B40,X   ; Letter
         STA $2180       ; Add to string
         INX             ; Index +1
         DEY             ; One less char
         BNE C33598      ; Loop till last
         LDA #$FF        ; Space char
         STA $2180       ; Add to string
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Draw equipped esper
C335AE:  JSR C335E1      ; Set pos/WRAM/Y
         LDA $001E,Y     ; Actor's esper
         CMP #$FF        ; None?
         BEQ C335D0      ; Blank if so
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         TAX             ; Index it
         LDY #$0008      ; Letters: 8
C335BF:  LDA $ED750E,X   ; Letter			=== SNES: $E6F6E1
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C335BF      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Blank esper name
C335D0:  LDY #$0008      ; Letters: 8
         LDA #$FF        ; Space char
C335D5:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C335D5      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Prepare name drawing
C335E1:  LDX #$9E89      ; 7E/9E89
         STX $2181       ; Set WRAM LBs
         REP #$20        ; 16-bit A
         TYA             ; Tilemap ptr
         SEP #$20        ; 8-bit A
         STA $2180       ; Set position LB
         XBA             ; Switch to HB
         STA $2180       ; Set position HB
         TDC             ; Clear A
         LDY $67         ; Actor address
         RTS

; Reset OAM and anim queue; disable screen, interrupts, pad, HDMA
C335F7:  LDA #$80        ; BRT:0 and OFF
         STA $2100       ; Disable screen
         JSR C3117F      ; Reset OAM, queue
         STZ $4200       ; Disable INT, pad
         STZ $420B       ; Disable DMA...
         STZ $420C       ; Disable HDMA
         RTS

; Prepare fade-in
C33609:  LDA #$01        ; BRT: 1 and ON
         STA $44         ; Set brightness
         JMP C313D3      ; Refresh screen

; Redraw time in main menu
C33610:  JSR C30FA4      ; Queue BG3 upload
         JMP C33307      ; Draw time

; Queue main screen designation HDMA for main menu
C33616:  LDX $00         ; Index: 0
         LDA #$17        ; BG1-3, sprites
C3361A:  STA $7E9A09,X   ; Set MS desig.
         INX             ; Index +1
         CPX #$00DF      ; At 7E/9AE8?
         BNE C3361A      ; Loop if not
         LDA #$40        ; 1Rx1B via ptrs
         STA $4360       ; Set DMA mode
         LDA #$2C        ; $212C
         STA $4361       ; To MS desig.
         LDY #C33643     ; C3/3643
         STY $4362       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4364       ; Set src HB
         LDA #$7E        ; Bank: 7E
         STA $4367       ; Set indir HB
         LDA #$40        ; Channel: 6
         TSB $43         ; Queue HDMA-6
         RTS

; Main screen designation table for main menu
C33643:  db $F0,$09,$9A  ; 112 lines, use $9A09
         db $F0,$79,$9A  ; 112 lines, use $9A79
         db $00          ; End

; Queue member swap animation for Order menu
C3364A:  LDA $28         ; First choice
         CMP $4B         ; Above second?
         BCC C33665      ; Branch if so
         LDA #$03        ; Min slot: 24
         LDY #C3369C     ; C3/369C
         JSR C311DE      ; Queue B's anim
         JSR C33689      ; Set slot B's Y
         LDA #$03        ; Min slot: 24
         LDY #C336E7     ; C3/36E7
         JSR C311DE      ; Queue A's anim
         BRA C3367A      ; Set slot A's Y

; Fork: First choice is above second
C33665:  LDA #$03        ; Min slot: 24
         LDY #C3369C     ; C3/369C
         JSR C311DE      ; Queue A's anim
         JSR C3367A      ; Set slot A's Y
         LDA #$03        ; Min slot: 24
         LDY #C336E7     ; C3/36E7
         JSR C311DE      ; Queue B's anim
         BRA C33689      ; Set slot B's Y

; Fork: Set base scanline for slot A
C3367A:  TXY             ; Queue index
         TDC             ; Clear A
         LDA $28         ; Chosen slot A
         TAX             ; Index it
         LDA.L C33698,X  ; Base scanline
         TYX             ; Queue index
         STA $7E33CA,X   ; Put in queue
         RTS

; Fork: Set base scanline for slot B
C33689:  TXY             ; Queue index
         TDC             ; Clear A
         LDA $4B         ; Chosen slot B
         TAX             ; Index it
         LDA.L C33698,X  ; Base scanline
         TYX             ; Queue index
         STA $7E33CA,X   ; Put in queue
         RTS

; Base scanlines for member swap animation
C33698:  db $0D          ; Member slot 1
         db $3D          ; Member slot 2
         db $6D          ; Member slot 3
         db $9D          ; Member slot 4

; Erase member slot contents from the top down, and vice versa
C3369C:  TAX             ; Index mode
         JMP (C336A0,X)  ; Handle mode

; Jump table for the above
C336A0:  dw C336A6       ; Pointless...
         dw C336AB       ; Erase 4 lines
         dw C336CA       ; Print 4 lines

; Mode 0: Erase 4 lines, advance mode...
C336A6:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1

; Mode 1: Erase 4 lines
C336AB:  LDY $2D         ; Queue index
         LDA $22         ; Time left
         CMP #$0C        ; 12 frames?
         BEQ C336C2      ; Unmask if so
         TDC             ; Clear A
         LDA $33CA,Y     ; Scanline
         TAX             ; Index it
         LDA #$06        ; On MS: BG2+BG3
         JSR C3373F      ; Hide 4 lines
         STA $33CA,Y     ; Save scanline
         SEC             ; Set to requeue
         RTS

; Fork: Start unmasking
C336C2:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         DEC $33CA,X     ; Scanline -1

; Mode 2: Print 4 lines
C336CA:  LDA $45         ; Menu flags
         BIT #$08        ; Got go-signal?
         BEQ C336E3      ; Exit if not
         LDY $2D         ; Queue index
         LDA $22         ; Timer expired?
         BEQ C336E5      ; Dequeue if so
         TDC             ; Clear A
         LDA $33CA,Y     ; Scanline
         TAX             ; Index it
         LDA #$17        ; On MS: BGs+OBJ
         JSR C33755      ; Unhide 4 lines
         STA $33CA,Y     ; Save scanline
C336E3:  SEC             ; Set to requeue
         RTS             ; Exit
C336E5:  CLC             ; Set to dequeue
         RTS

; Erase member slot contents from the bottom up, and vice versa
C336E7:  TAX             ; Index mode
         JMP (C336EB,X)  ; Handle mode

; Jump table for the above
C336EB:  dw C336F1       ; Start from bottom
         dw C336FF       ; Erase 4 lines
         dw C33720       ; Print 4 lines

; Mode 0: Start from bottom
C336F1:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA $33CA,X     ; Top scanline
         CLC             ; Prepare ADC
         ADC #$2F        ; Go 47 px down
         STA $33CA,X     ; Save changes

; Mode 1: Erase 4 lines
C336FF:  LDY $2D         ; Queue index
         LDA $22         ; Time left
         CMP #$0C        ; 12 frames?
         BEQ C33718      ; Unmask if so
         TDC             ; Clear A
         LDA $33CA,Y     ; Scanline
         TAX             ; Index it
         LDA #$06        ; On MS: BG2+BG3
         JSR C33755      ; Hide 4 lines
         STA $33CA,Y     ; Save scanline
         DEC $22         ; Anim timer -1
         SEC             ; Set to requeue
         RTS

; Fork: Start ummasking
C33718:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         INC $33CA,X     ; Scanline +1

; Mode 2: Print 4 lines
C33720:  LDA $45         ; Menu flags
         BIT #$08        ; Got go-signal?
         BEQ C3373B      ; Exit if not
         LDY $2D         ; Queue index
         LDA $22         ; Timer expired?
         BEQ C3373D      ; Dequeue if so
         TDC             ; Clear A
         LDA $33CA,Y     ; Scanline
         TAX             ; Index it
         LDA #$17        ; On MS: BGs+OBJ
         JSR C3373F      ; Unhide 4 lines
         STA $33CA,Y     ; Save scanline
         DEC $22         ; Anim timer -1
C3373B:  SEC             ; Set to requeue
         RTS             ; Exit
C3373D:  CLC             ; Set to dequeue
         RTS

; Enable or disable desired layers on next 4 lines below
C3373F:  STA $7E9A09,X   ; MS desig L1
         INX             ; Scanline +1
         STA $7E9A09,X   ; MS desig L2
         INX             ; Scanline +1
         STA $7E9A09,X   ; MS desig L3
         INX             ; Scanline +1
         STA $7E9A09,X   ; MS desig L4
         INX             ; Scanline +1
         TXA             ; Line number
         RTS

; Enable or disable desired layers on next 4 lines above
C33755:  STA $7E9A09,X   ; MS desig L4
         DEX             ; Scanline -1
         STA $7E9A09,X   ; MS desig L3
         DEX             ; Scanline -1
         STA $7E9A09,X   ; MS desig L2
         DEX             ; Scanline -1
         STA $7E9A09,X   ; MS desig L1
         DEX             ; Scanline -1
         TXA             ; Line number
         RTS

; Set to condense BG3 text in main menu
C3376B:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C3378A     ; C3/378A
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Text shifting table for the above
C3378A:  db $0F,$00,$00  ; Nothing
         db $0F,$03,$00  ; Item
         db $0F,$04,$00  ; Skills
         db $0F,$05,$00  ; Equip
         db $0F,$06,$00  ; Relic
         db $0F,$07,$00  ; Status
         db $0F,$08,$00  ; Config
         db $0F,$09,$00  ; Save
         db $07,$08,$00  ; Nothing
         db $08,$00,$00  ; Nothing
         db $08,$00,$00  ; Time
         db $18,$00,$00  ; The rest
         db $00          ; End

; 65: Shift screen left or right
C337AF:  LDA $20         ; Timer expired?
         BNE C337B7      ; Branch if not
         LDA $27         ; Queued command
         STA $26         ; Execute it next
C337B7:  REP #$20        ; 16-bit A
         LDA $35         ; BG1 X-Pos
         CLC             ; Prepare ADC
         ADC $9C         ; Add scroll speed
         STA $35         ; Set BG1 X-Pos
         STA $39         ; Set BG2 X-Pos
         STA $3D         ; Set BG3 X-Pos
         SEP #$20        ; 8-bit A
         RTS

; Load navigation data for non-shifted Status menu
C337C7:  LDY #C337D6     ; C3/37D6
         JMP C30681      ; Load navig data

; Handle D-Pad for non-shifted Status menu
C337CD:  JSR C307B0      ; Handle D-Pad
C337D0:  LDY #C337DB     ; C3/37DB
         JMP C306C3      ; Relocate cursor

; Navigation data for non-shifted Status menu
C337D6:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $04          ; 4 rows

; Cursor positions for non-shifted Status menu
C337DB:  dw $5990        ; Command 1
         dw $6590        ; Command 2
         dw $7190        ; Command 3
         dw $7D90        ; Command 4

; Text, "Wounded "
C337E3:  db |せんとうふのう |

; Text pointers for main menu and save file submenus
C337EB:  dw C338C5       ; TIME
         dw C338D0       ; Steps
         dw C33920       ; Order
C337F1:  dw C33893       ; Item
         dw C3389A       ; Skills
         dw C338A7       ; Relic
         dw C338AF       ; Status
C337F9:  dw C33846       ; /
         dw C3384A       ; /
C337FD:  dw C3385D       ; /
         dw C33861       ; /
C33801:  dw C33874       ; /
         dw C33878       ; /
C33805:  dw C3388B       ; /
         dw C3388F       ; /
C33809:  dw C33837       ; LV
         dw C3383C       ; HP
         dw C33841       ; MP
C3380F:  dw C3384E       ; LV
         dw C33853       ; HP
         dw C33858       ; MP
C33815:  dw C33865       ; LV
         dw C3386A       ; HP
         dw C3386F       ; MP
C3381B:  dw C3387C       ; LV
         dw C33881       ; HP
         dw C33886       ; MP
C33821:  dw C338A1       ; Equip
         dw C338B7       ; Config
C33825:  dw C338DB       ; Yes
         dw C338E0       ; No
         dw C338E6       ; This
         dw C338EF       ; data?
C3382D:  dw C338DB       ; Yes
         dw C338E0       ; No
         dw C338F9       ; Erasing
         dw C33902       ; data.
         dw C3390C       ; Okay?

; Positioned text for main menu and save file submenus
C33837:  dw $399D : db "LV",$00
C3383C:  dw $39DD : db "HP",$00
C33841:  dw $3A1D : db "MP",$00
C33846:  dw $39EB : db "/",$00
C3384A:  dw $3A2B : db "/",$00
C3384E:  dw $3B1D : db "LV",$00
C33853:  dw $3B5D : db "HP",$00
C33858:  dw $3B9D : db "MP",$00
C3385D:  dw $3B6B : db "/",$00
C33861:  dw $3BAB : db "/",$00
C33865:  dw $3C9D : db "LV",$00
C3386A:  dw $3CDD : db "HP",$00
C3386F:  dw $3D1D : db "MP",$00
C33874:  dw $3CEB : db "/",$00
C33878:  dw $3D2B : db "/",$00
C3387C:  dw $3E1D : db "LV",$00
C33881:  dw $3E5D : db "HP",$00
C33886:  dw $3E9D : db "MP",$00
C3388B:  dw $3E6B : db "/",$00
C3388F:  dw $3EAB : db "/",$00
C33893:  dw $793B : db |アイテム[end]|	; Item			=== SNES: Shifted leftward as longer (same below)
C3389A:  dw $79BB : db |とくしゅ[end]|	; Skills
C338A1:  dw $79FB : db |そうび[end]|	; Equip
C338A7:  dw $7ABB : db |アクセサリ[end]|	; Relic
C338AF:  dw $7B3B : db |ステータス[end]|	; Status
C338B7:  dw $7B7B : db |コンフィグ[end]|	; Config
C338BF:  dw $7BFB : db |セーブ[end]|	; Save
C338C5:  dw $7CBB : db "TIME",$00				=== SNES: Not fully capitalized
C338CC:  dw $7CFF : db ":",$00
C338D0:  dw $7DB7 : db |ほすう[end]|	; Steps
C338D6:  dw $7E37 : db |ギル[end]|	; Gp
C338DB:  dw $7A7D : db |はい[end]|	; Yes
C338E0:  dw $7AFD : db |いいえ[end]|	; No
C338E6:  dw $78F7 : db |このデータで[end]|	; This
C338EF:  dw $7977 : db |はじめますか?[end]|	; data?
C338F9:  dw $78F7 : db |これをけして[end]|	; Erasing
C33902:  dw $7977 : db |かきこみます。[end]|	; data.
C3390C:  dw $79F7 : db |いいですか?[end]|	; Okay?
C33915:  dw $7C77 : db |セーブしました。[end]|	; Saved. (unused)	%%%
C33920:  dw $813D : db |たいけい[end]|	; Order

; Load navigation data for Config page 1
C33927:  LDY #C33936     ; C3/3936
         JMP C30681      ; Load navig data

; Handle D-Pad for Config page 1
C3392D:  JSR C307B0      ; Handle D-Pad
C33930:  LDY #C3393B     ; C3/393B
         JMP C306C3      ; Relocate cursor

; Navigation data for Config page 1
C33936:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $0A          ; 10 rows			=== SNES: 9 (no button settings menu)

; Cursor positions for Config page 1
C3393B:  dw $2960        ; Bat.Mode
         dw $3960        ; Bat.Speed
         dw $4960        ; Msg.Speed
         dw $5960        ; Cmd.Set
         dw $6960        ; Gauge
         dw $7960        ; Sound
         dw $8960        ; Cursor
         dw $9960        ; Reequip
         dw $A960        ; Button			%%%
         dw $B960        ; Controller			=== SNES: Shifted up as no Button Settings menu

; Load navigation data for Config page 2
C3394F:  LDY #C3395E     ; C3/395E
         JMP C30681      ; Load navig data

; Handle D-Pad for Config page 2
C33955:  JSR C307B0      ; Handle D-Pad
C33958:  LDY #C33963     ; C3/3963
         JMP C306C3      ; Relocate cursor

; Navigation data for Config page 2
C3395E:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $06          ; 6 rows

; Cursor positions for Config page 2
C33963:  dw $2960        ; Mag.Order
         dw $6960        ; Window
         dw $7960        ; Color
         dw $9960        ; R
         dw $A960        ; G
         dw $B960        ; B

; Draw Config menu, load navigation data, create arrow
C3396F:  LDA #$02        ; 32x64 at $0000
         STA $2107       ; Set BG1 map loc
         LDY #$FFFB      ; Y: -5
         STY $3F         ; Set BG3 Y-Pos
         JSR C371BC      ; Clear BG2 map A
         LDY #C33AB6     ; C3/3AB6
         JSR C303C4      ; Draw main window
         LDY #C33ABA     ; C3/3ABA
         JSR C303C4      ; Draw title window
         JSR C30EBD      ; Upload windows
         JSR C33A32      ; Load gauge colors
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C34E8F     ; Text pointer
         JSR C30326      ; Draw "Config"
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C34E81     ; Text ptrs loc
         LDY #$000E      ; Strings: 7
         JSR C3714E      ; Draw Bat.Mode, etc.
         LDA #$24        ; ...
         STA $29         ; ...
         LDX #C34DF5     ; Text ptrs loc
         LDY #$0004      ; Strings: 2
         JSR C3712C      ; Draw Cursor, Contr.
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C34DF9     ; Text ptrs loc
         LDY #$0004      ; Strings: 2
         JSR C3712C      ; Draw Fast, Slow
         JSR C33C60      ; Draw Active, Wait
         JSR C33C8B      ; Draw Bat.Spd nums
         JSR C33CC6      ; Draw Msg.Spd nums
         JSR C33D07      ; Draw Window, Short
         JSR C33D30      ; Draw On and Off
         JSR C33D59      ; Draw Stereo, Mono
         JSR C33D84      ; Draw Reset, Memory
         JSR C33DAF      ; Draw Optimum, Empty
         JSR C33DDA      ; Draw Btn.Set options		%%%
         JSR C33E0B      ; Draw Single/Multiple
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C34EF4     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3714E      ; Draw page-2 titles
         JSR C33A24      ; Draw empty gauges
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C34F00     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3712C      ; Draw 1/2/3, R/G/B
         JSR C3411D      ; Draw M.Order options
         JSR C341CB      ; Draw skin numbers
         JSR C34214      ; Draw skin palette
         JSR C342A4      ; Draw RGB info
         JSR C33AC9      ; Get nav data; BG1 Y
         JSR C30E93      ; Upload BG1 A+B
         JSR C30ED9      ; Upload BG3 A+B
         LDA #$01        ; Min slot: 8
         LDY #C33A54     ; C3/3A54
         JSR C311DE      ; Queue arrow OAM
         RTS

; Draw empty color gauges
C33A24:  LDA #$30        ; Palette 4
         STA $29         ; Color: Gray
         LDX #C34EFA     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw text
         RTS

; Load color gauge palette
C33A32:  LDX $00         ; Color index: 0
         LDA #$40        ; CGRAM: $0080
         STA $2121       ; To BG pal 4
C33A39:  REP #$20        ; 16-bit A
         LDA $D8E880,X   ; Font color
         STA $7E30C9,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         STA $2122       ; Put LB in CGRAM
         XBA             ; Switch to HB
         STA $2122       ; Put HB in CGRAM
         INX             ; Color index +1
         INX             ; Color index +1
         CPX #$0020      ; Done 16 colors?
         BNE C33A39      ; Loop if not
         RTS

; Update arrow in Config menu
C33A54:  TAX             ; Index mode
         JMP (C33A58,X)  ; Handle mode

; Jump table for the above
C33A58:  dw C33A5C       ; Initialize arrow
         dw C33A7F       ; Sustain arrow

; Mode 0: Initialize arrow
C33A5C:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #C33A9F     ; Anim table ptr
         STA $32C9,X     ; Set arrow's
         LDA #$0078      ; X: 120
         STA $33CA,X     ; Set arrow's
         LDA #$0018      ; Base Y: 24
         STA $344A,X     ; Set arrow's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer

; Mode 1: Sustain arrow
C33A7F:  LDY $2D         ; Queue index
         LDA $4A         ; On first page?
         BEQ C33A89      ; Branch if so
         LDA #$02        ; Arrow: Up
         BRA C33A8A      ; Skip a line
C33A89:  TDC             ; Arrow: Down
C33A8A:  TAX             ; Set index
         REP #$20        ; 16-bit A
         LDA.L C33A9B,X  ; Anim table ptr
         STA $32C9,Y     ; Set arrow's
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Pointers for Config's large arrows
C33A9B:  dw C33A9F       ; Downward arrow
         dw C33AA8       ; Upward arrow

; Animation table for large downward arrow in Config menu
C33A9F:  dw C3C3B5       ; Hide arrow
         db $10          ; Frames: 16
         dw C33AB1       ; Show arrow
         db $10          ; Frames: 16
         dw C3C3B5       ; Bogus...
         db $FF          ; Loop

; Animation table for large upward arrow in Config menu
C33AA8:  dw C3C3B5       ; Hide arrow
         db $10          ; Frames: 16
         dw C3C3BB       ; Show arrow
         db $10          ; Frames: 16
         dw C3C3B5       ; Bogus...
         db $FF          ; Loop

; OAM for large downward arrow in Config menu
C33AB1:  db $01          ; Tiles: 1
         dw $B080        ; 16x16, X+0, Y+176
         dw $3E03        ; Tile 3, pal 7, prio 3

; Window layout for Config menu
C33AB6:  dw $590B,$161C  ; 30x24 at $590B (Main)
C33ABA:  dw $58B9,$0205  ; 07x04 at $58B9 (Title)	=== SNES: Expanded leftward

; Switch to Config page 2
C33ABE:  LDY #$00FB      ; Y: 251
         STY $37         ; Set BG1 Y-Pos
         JSR C3394F      ; Load navig data
         JMP C33958      ; Relocate cursor

; Switch to Config page 1
C33AC9:  LDY #$FFFB      ; Y: -5
         STY $37         ; Set BG1 Y-Pos
         JSR C33927      ; Load navig data
         JMP C33930      ; Relocate cursor

; 50: Scroll to Config page 2
C33AD4:  LDA $20         ; Timer expired?
         BEQ C33AE9      ; Finalize if so
         LDA $4A         ; On page 2?...
         BNE C33AF0      ; Branch if so
         REP #$20        ; 16-bit A
         LDA $37         ; BG1 Y-Pos
         CLC             ; Prepare ADC
         ADC #$0010      ; Move 16 px down
         STA $37         ; Save changes
         SEP #$20        ; 8-bit A
         RTS             ; Exit
C33AE9:  LDA #$01        ; Screen: 2nd
         STA $4A         ; Set active page
         JSR C33ABE      ; Switch screens
C33AF0:  LDA #$0E        ; C3/2325
         STA $26         ; Next: Sustain menu
         RTS

; 51: Scroll to Config page 1
C33AF5:  LDA $20         ; Timer expired?
         BEQ C33B0A      ; Finalize if so
         LDA $4A         ; On page 1?...
         BEQ C33B1B      ; Branch if so
         REP #$20        ; 16-bit A
         LDA $37         ; BG1 Y-Pos
         SEC             ; Prepare SBC
         SBC #$0010      ; Move 16 px up
         STA $37         ; Save changes
         SEP #$20        ; 8-bit A
         RTS             ; Exit
C33B0A:  STZ $4A         ; Page: 1st
         LDY #$FFFB      ; Y: -5
         STY $37         ; Set BG1 Y-Pos
         JSR C33927      ; Load navig data
         LDA #$09        ; Row: Controller		=== SNES: 8 (no Button Settings menu)
         STA $4E         ; Set cursor row
         JSR C33930      ; Relocate cursor
C33B1B:  LDA #$0E        ; C3/2325
         STA $26         ; Next: Sustain menu
         RTS

; Set Window 2 positions per scanline for Config menu
C33B20:  LDA #$01        ; 2Rx1B to PPU
         STA $4350       ; Set DMA mode
         LDA #$28        ; $2128, $2129
         STA $4351       ; To Win 2 L+R
         LDY #C33B4E     ; C3/3B4E
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Set Window 2 positions for main menu
C33B3F:  LDA #$20        ; Channel: 5
         TRB $43         ; Halt HDMA-5
         LDA #$08        ; X: 8
         STA $2128       ; Set left loc
         LDA #$F7        ; X: 247
         STA $2129       ; Set right loc
         RTS

; Window 2 positions per scanline for Config menu
C33B4E:  db $27,$FF,$FF  ; 39 lines: 255, 255
         db $50,$08,$F7  ; 80 lines: 8, 247
         db $50,$08,$F7  ; 80 lines: 8, 247
         db $10,$FF,$FF  ; 16 lines: 255, 255
         db $00          ; End

; Upload skin graphics, load colors and tile attributes
C33B5B:  LDY #$7800      ; $7800
         STY $14         ; Set VRAM ptr
         LDA $1D4E       ; Skin, etc.
         JSR C33C04      ; Set source
         LDA $1D4E       ; Skin, etc.
         LDX #$0060      ; To 7E/312B
         JSR C33C2F      ; Load colors
         LDY #$1C00      ; Palette: 7
         JMP C303A9      ; Build skin map

; Upload skin for save file 1
C33B75:  LDY #$7A00      ; $7A00
         STY $14         ; Set VRAM ptr
         LDY $91         ; Blank file?
         BEQ C33B84      ; Branch if so
         LDA $30674E     ; Skin, etc.
         BRA C33B85      ; Skip a line
C33B84:  TDC             ; Use skin 1
C33B85:  JSR C33C04      ; Set source
         JSR C314F3      ; Upload skin
         LDY #$1820      ; Tile+32, pal 6
         JMP C303A9      ; Build skin map

; Upload skin for save file 2
C33B91:  LDY #$7C00      ; $7C00
         STY $14         ; Set VRAM ptr
         LDY $93         ; Blank file?
         BEQ C33BA0      ; Branch if so
         LDA $30714E     ; Skin, etc.
         BRA C33BA1      ; Skip a line
C33BA0:  TDC             ; Use skin 1
C33BA1:  JSR C33C04      ; Set source
         JSR C314F3      ; Upload skin
         LDY #$1440      ; Tile+64, pal 5
         JMP C303A9      ; Build skin map

; Upload skin for save file 3
C33BAD:  LDY #$7E00      ; $7E00
         STY $14         ; Set VRAM ptr
         LDY $95         ; Blank file?
         BEQ C33BBC      ; Branch if so
         LDA $307B4E     ; Skin, etc.
         BRA C33BBD      ; Skip a line
C33BBC:  TDC             ; Use skin 1
C33BBD:  JSR C33C04      ; Set source
         JSR C314F3      ; Upload skin
         LDY #$1060      ; Tile+96, pal 4
         JMP C303A9      ; Build skin map

; Load skin colors for save file 1
C33BC9:  LDY $91         ; Blank file?
         BEQ C33BD3      ; Branch if so
         LDA $30674E     ; Skin, etc.
         BRA C33BD4      ; Skip a line
C33BD3:  TDC             ; Use skin 1
C33BD4:  LDX #$0040      ; To 7E/310B
         JSR C33C2F      ; Load colors
         JMP C3153D      ; Refresh CGRAM

; Load skin colors for save file 2
C33BDD:  LDY $93         ; Blank file?
         BEQ C33BE7      ; Branch if so
         LDA $30714E     ; Skin, etc.
         BRA C33BE8      ; Skip a line
C33BE7:  TDC             ; Use skin 1
C33BE8:  LDX #$0020      ; To 7E/30EB
         JSR C33C2F      ; Load colors
         JMP C3153D      ; Refresh CGRAM

; Load skin colors for save file 3
C33BF1:  LDY $95         ; Blank file?
         BEQ C33BFB      ; Branch if so
         LDA $307B4E     ; Skin, etc.
         BRA C33BFC      ; Skip a line
C33BFB:  TDC             ; Use skin 1
C33BFC:  LDX $00         ; To 7E/30CB
         JSR C33C2F      ; Load colors
         JMP C3153D      ; Refresh CGRAM

; Set source for uploading skin graphics
C33C04:  AND #$0F        ; Skin number
         STA $E0         ; Set counter
         STZ $E1         ; Clear HB
         LDY #$0000      ; ED/0000
         STY $16         ; Set src LBs
         LDA #$ED        ; Bank: ED
         STA $18         ; Set src HB
         REP #$20        ; 16-bit A
         TDC             ; Source mod: 0
C33C16:  LDY $E0         ; Loop counter
         BEQ C33C22      ; Branch if 0
         CLC             ; Prepare ADC
         ADC #$0380      ; Adjust src mod
         DEC $E0         ; Counter -1
         BRA C33C16      ; Loop
C33C22:  CLC             ; Prepare ADC
         ADC $16         ; Add src LBs
         STA $16         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDY #$0400      ; Bytes: 1024
         STY $12         ; Set data size
         RTS

; Apply player's skin colors
C33C2F:  AND #$0F        ; Skin number
         STA $E0         ; Set counter
         PHX             ; ...
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         STZ $E1         ; Counter HB: 0
         REP #$20        ; 16-bit A
         LDA #$1D57      ; Base: 7E/1D57
C33C3F:  LDY $E0         ; Loop counter
         BEQ C33C4B      ; Branch if 0
         CLC             ; Prepare ADC
         ADC #$000E      ; Skip 7 colors
         DEC $E0         ; Counter -1
         BRA C33C3F      ; Loop
C33C4B:  STA $E7         ; Set source LBs
         SEP #$20        ; 8-bit A
         LDY $00         ; Src index: 0
         PLX             ; ...
C33C52:  LDA [$E7],Y     ; Player color
         STA $7E30CB,X   ; Put in palette
         INY             ; Src index +1
         INX             ; Dst index +1
         CPY #$000E      ; Done 7 colors?
         BNE C33C52      ; Loop if not
         RTS

; Draw Bat.Mode settings
C33C60:  LDA $1D4D       ; Game options
         AND #$08        ; Wait mode?
         BEQ C33C70      ; Branch if not
         LDA #$28        ; Color: Gray
         JSR C33C79      ; Draw "Active"
         LDA #$20        ; Color: User's
         BRA C33C82      ; Draw "Wait"

; Fork: Active mode
C33C70:  LDA #$20        ; Color: User's
         JSR C33C79      ; Draw "Active"
         LDA #$28        ; Color: Gray
         BRA C33C82      ; Draw "Wait"

; Fork: Draw "Active"
C33C79:  STA $29         ; Set palette
         LDY #C34ECE     ; Text pointer
         JSR C30326      ; Draw "Active"
         RTS

; Fork: Draw "Wait"
C33C82:  STA $29         ; Set palette
         LDY #C34E07     ; Text pointer
         JSR C302F9      ; Draw "Wait"
         RTS

; Draw Bat.Speed values
C33C8B:  LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         LDY #C34E5C     ; Text pointer
         JSR C302F9      ; Draw 1-6 in gray
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         TDC             ; Clear A
         LDA $1D4D       ; Game options
         AND #$07        ; Get Bat.Speed
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C33CBA,X  ; Tilemap ptr
         STA $F7         ; Set position
         SEP #$20        ; 8-bit A
         LDA $1D4D       ; Game options
         AND #$07        ; Get Bat.Speed
         CLC             ; ...
         ADC #$54        ; Convert to text		=== SNES: Different base tile number
         STA $F9         ; Add to string
         STZ $FA         ; End string
         JMP C341F7      ; Draw user speed

; Tilemap pointers for Bat.Speed values
C33CBA:  dw $3A25        ; 1
         dw $3A29        ; 2
         dw $3A2D        ; 3
         dw $3A31        ; 4
         dw $3A35        ; 5
         dw $3A39        ; 6

; Draw Msg.Speed values
C33CC6:  LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         LDY #C34E6A     ; Text pointer
         JSR C302F9      ; Draw 1-6 in gray
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         TDC             ; Clear A
         LDA $1D4D       ; Game options
         AND #$70        ; Get Msg.Speed
         LSR A           ; ÷2
         LSR A           ; ÷4
         LSR A           ; ÷8
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C33CFB,X  ; Tilemap ptr
         STA $F7         ; Set position
         SEP #$20        ; 8-bit A
         LDA $1D4D       ; Game options
         AND #$70        ; Get Msg.Speed
         LSR A           ; ÷2
         LSR A           ; ÷4
         LSR A           ; ÷8
         LSR A           ; Now 0-7
         CLC             ; ...
         ADC #$54        ; Convert to text		=== SNES: Different base tile number
         STA $F9         ; Add to string
         STZ $FA         ; End string
         JMP C341F7      ; Draw user speed

; Tilemap pointers for Msg.Speed values
C33CFB:  dw $3AA5        ; 1
         dw $3AA9        ; 2
         dw $3AAD        ; 3
         dw $3AB1        ; 4
         dw $3AB5        ; 5
         dw $3AB9        ; 6

; Draw Cmd.Set settings
C33D07:  LDA $1D4D       ; Short mode?
         BMI C33D15      ; Branch if so
         LDA #$28        ; Color: Gray
         JSR C33D1E      ; Draw "Short"
         LDA #$20        ; Color: User's
         BRA C33D27      ; Draw "Window"

; Fork: Short mode
C33D15:  LDA #$20        ; Color: User's
         JSR C33D1E      ; Draw "Short"
         LDA #$28        ; Color: Gray
         BRA C33D27      ; Draw "Window"

; Fork: Draw "Short"
C33D1E:  STA $29         ; Set palette
         LDY #C34E1A     ; Text pointer
         JSR C302F9      ; Draw "Short"
         RTS

; Fork: Draw "Window"
C33D27:  STA $29         ; Set palette
         LDY #C34ED6     ; Text pointer
         JSR C30326      ; Draw "Window"
         RTS

; Draw Gauge settings
C33D30:  LDA $1D4E       ; Gauges on?
         BPL C33D3E      ; Branch if so
         LDA #$28        ; Color: Gray
         JSR C33D47      ; Draw "On"
         LDA #$20        ; Color: User's
         BRA C33D50      ; Draw "Off"

; Fork: Gauges on
C33D3E:  LDA #$20        ; Color: User's
         JSR C33D47      ; Draw "On"
         LDA #$28        ; Color: Gray
         BRA C33D50      ; Draw "Off"

; Fork: Draw "On"
C33D47:  STA $29         ; Set palette
         LDY #C34E22     ; Text pointer
         JSR C302F9      ; Draw "On"
         RTS

; Fork: Draw "Off"
C33D50:  STA $29         ; Set palette
         LDY #C34E27     ; Text pointer
         JSR C302F9      ; Draw "Off"
         RTS

; Draw Sound settings
C33D59:  LDA $1D4E       ; Game options
         AND #$20        ; Stereo?
         BEQ C33D69      ; Branch if so
         LDA #$28        ; Color: Gray
         JSR C33D72      ; Draw "Stereo"
         LDA #$20        ; Color: User's
         BRA C33D7B      ; Draw "Mono"

; Fork: Stereo mode
C33D69:  LDA #$20        ; Color: User's
         JSR C33D72      ; Draw "Stereo"
         LDA #$28        ; Color: Gray
         BRA C33D7B      ; Draw "Mono"

; Fork: Draw "Stereo"
C33D72:  STA $29         ; Set palette
         LDY #C34E2C     ; Text pointer
         JSR C302F9      ; Draw "Stereo"
         RTS

; Fork: Draw "Mono"
C33D7B:  STA $29         ; Set palette
         LDY #C34E33     ; Text pointer
         JSR C302F9      ; Draw "Mono"
         RTS

; Draw Cursor settings
C33D84:  LDA $1D4E       ; Game options
         AND #$40        ; Cursor memory?
         BEQ C33D94      ; Branch if not
         LDA #$28        ; Color: Gray
         JSR C33D9D      ; Draw "Reset"
         LDA #$20        ; Color: User's
         BRA C33DA6      ; Draw "Memory"

; Fork: Reset mode
C33D94:  LDA #$20        ; Color: User's
         JSR C33D9D      ; Draw "Reset"
         LDA #$28        ; Color: Gray
         BRA C33DA6      ; Draw "Memory"

; Fork: Draw "Reset"
C33D9D:  STA $29         ; Set palette
         LDY #C34EDE     ; Text pointer
         JSR C30326      ; Draw "Reset"
         RTS

; Fork: Draw "Memory"
C33DA6:  STA $29         ; Set palette
         LDY #C34E3A     ; Text pointer
         JSR C302F9      ; Draw "Memory"
         RTS

; Draw Reequip settings
C33DAF:  LDA $1D4E       ; Game options
         AND #$10        ; Optimum mode?
         BEQ C33DBF      ; Branch if so
         LDA #$28        ; Color: Gray
         JSR C33DC8      ; Draw "Optimum"
         LDA #$20        ; Color: User's
         BRA C33DD1      ; Draw "Empty"

; Fork: Optimum mode
C33DBF:  LDA #$20        ; Color: User's
         JSR C33DC8      ; Draw "Optimum"
         LDA #$28        ; Color: Gray
         BRA C33DD1      ; Draw "Empty"

; Fork: Draw "Optimum"
C33DC8:  STA $29         ; Set palette
         LDY #C34E40     ; Text pointer
         JSR C302F9      ; Draw "Optimum"
         RTS

; Fork: Draw "Empty"
C33DD1:  STA $29         ; Set palette
         LDY #C34EE4     ; Text pointer
         JSR C30326      ; Draw "Empty"
         RTS

; Draw Btn.Set settings					%%%
C33DDA:  LDA $1D54       ; Game options
         AND #$40        ; Default keys?
         BEQ C33DED      ; Branch if so
         JSR C3ADEF      ; Apply user keys
         LDA #$28        ; Color: Gray
         JSR C33DF9      ; Draw "Normal"
         LDA #$20        ; Color: User's
         BRA C33E02      ; Draw "Custom"

; Fork: Normal mode
C33DED:  JSR C3ADFC      ; Reset buttons
         LDA #$20        ; Color: User's
         JSR C33DF9      ; Draw "Normal"
         LDA #$28        ; Color: Gray
         BRA C33E02      ; Draw "Custom"

; Fork: Draw "Normal"
C33DF9:  STA $29         ; Set palette
         LDY #C34E48     ; Text pointer
         JSR C302F9      ; Draw "Normal"
         RTS

; Fork: Draw "Custom"
C33E02:  STA $29         ; Set palette
         LDY #C34E4F     ; Text pointer
         JSR C302F9      ; Draw "Custom"
         RTS

; Draw Controller settings
C33E0B:  LDA $1D54       ; Solo mode?
         BPL C33E19      ; Branch if so
         LDA #$28        ; Color: Gray
         JSR C33E22      ; Draw "Single"
         LDA #$20        ; Color: User's
         BRA C33E2B      ; Draw "Multiple"

; Fork: Single mode
C33E19:  LDA #$20        ; Color: User's
         JSR C33E22      ; Draw "Single"
         LDA #$28        ; Color: Gray
         BRA C33E2B      ; Draw "Multiple"

; Fork: Draw "Single"
C33E22:  STA $29         ; Set palette
         LDY #C34EED     ; Text pointer
         JSR C30326      ; Draw "Single"
         RTS

; Fork: Draw "Multiple"
C33E2B:  STA $29         ; Set palette
         LDY #C34E56     ; Text pointer
         JSR C302F9      ; Draw "Multiple"
         RTS

; Handle Config changes with D-Pad
C33E34:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $4A         ; On first page?
         BEQ C33E45      ; Branch if so
         PHX             ; ...
         JSR C30F0E      ; Sound: Cursor
         PLX             ; ...
         JMP (C33E5C,X)  ; Handle page 2
C33E45:  JMP (C33E48,X)  ; Handle page 1

; Jump table for updating game options
C33E48:  dw C33E68       ; Bat.Mode
         dw C33E81       ; Bat.Speed
         dw C33EB2       ; Msg.Speed
         dw C33EEF       ; Cmd.Set
         dw C33F08       ; Gauge
         dw C33F21       ; Sound
         dw C33F55       ; Cursor
         dw C33F74       ; Reequip
         dw C33F8D       ; Button			%%%
         dw C33FA6       ; Controller
C33E5C:  dw C33FBF       ; Mag.Order
         dw C33FED       ; Window
         dw C34021       ; Viewed color
         dw C3405C       ; R
         dw C3407B       ; G
         dw C3409A       ; B

; Update Bat.Mode
C33E68:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33E79      ; Branch if so
         LDA #$08        ; Mode: Active
         TRB $1D4D       ; Set option
         JMP C33C60      ; Redraw text
C33E79:  LDA #$08        ; Mode: Wait
         TSB $1D4D       ; Set option
         JMP C33C60      ; Redraw text

; Update Bat.Speed
C33E81:  JSR C30F0E      ; Sound: Cursor
         LDA $1D4D       ; Game options
         AND #$07        ; Get Bat.Speed
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C33E9C      ; Branch if not

; Fork: Bat.Speed +1
C33E91:  LDA $E0         ; Bat.Speed
         CMP #$05        ; Rightmost?
         BEQ C33E9B      ; Exit if so
         INC $E0         ; Speed +1
         BRA C33EA5      ; Apply changes
C33E9B:  RTS

; Fork: Bat.Speed -1
C33E9C:  LDA $E0         ; Leftmost speed?
         BEQ C33EA4      ; Exit if so
         DEC $E0         ; Speed -1
         BRA C33EA5      ; Apply changes
C33EA4:  RTS

; Fork: Apply Bat.Speed
C33EA5:  LDA $1D4D       ; Game options
         AND #$F8        ; Clear Bat.Speed
         ORA $E0         ; Set chosen speed
         STA $1D4D       ; Save changes
         JMP C33C8B      ; Redraw values

; Update Msg.Speed
C33EB2:  JSR C30F0E      ; Sound: Cursor
         LDA $1D4D       ; Game options
         AND #$70        ; Get Msg.Speed
         LSR A           ; Put in b3-b5
         LSR A           ; Put in b2-b4
         LSR A           ; Put in b1-b3
         LSR A           ; Now 0-5
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C33ED1      ; Branch if not

; Fork: Msg.Speed +1
C33EC6:  LDA $E0         ; Msg.Speed
         CMP #$05        ; Rightmost?
         BEQ C33ED0      ; Exit if so
         INC $E0         ; Speed +1
         BRA C33EDA      ; Apply changes
C33ED0:  RTS

; Fork: Msg.Speed -1
C33ED1:  LDA $E0         ; Leftmost speed?
         BEQ C33ED9      ; Exit if so
         DEC $E0         ; Speed -1
         BRA C33EDA      ; Apply changes
C33ED9:  RTS

; Fork: Apply Msg.Speed
C33EDA:  LDA $E0         ; Chosen speed
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         STA $E0         ; Save changes
         LDA $1D4D       ; Game options
         AND #$8F        ; Clear Msg.Speed
         ORA $E0         ; Set chosen speed
         STA $1D4D       ; Save changes
         JMP C33CC6      ; Redraw values

; Update Cmd.Set mode
C33EEF:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33F00      ; Branch if so
         LDA #$80        ; Mode: Window
         TRB $1D4D       ; Set option
         JMP C33D07      ; Redraw options
C33F00:  LDA #$80        ; Mode: Short
         TSB $1D4D       ; Set option
         JMP C33D07      ; Redraw options

; Update gauge mode
C33F08:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33F19      ; Branch if so
         LDA #$80        ; Gauge: On
         TRB $1D4E       ; Set option
         JMP C33D30      ; Redraw options
C33F19:  LDA #$80        ; Gauge: Off
         TSB $1D4E       ; Set option
         JMP C33D30      ; Redraw options

; Update sound mode
C33F21:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33F36      ; Branch if so
         TDC             ; Volume: Stereo
         JSR C33F46      ; Adjust volume
         LDA #$20        ; Mode: Stereo
         TRB $1D4E       ; Set option
         JSR C30F0E      ; Sound: Cursor
         JMP C33D59      ; Redraw options
C33F36:  LDA #$FF        ; Volume: Mono
         JSR C33F46      ; Adjust volume
         LDA #$20        ; Mono flag
         TSB $1D4E       ; Set mono mode
         JSR C30F0E      ; Sound: Cursor
         JMP C33D59      ; Redraw options

; Adjust volume based on sound mode (stereo = 0)
C33F46:  STA $001301     ; Set sound mode
         LDA #$F3        ; SPC code: $0D61
         STA $001300     ; Set SPC command
         JSL $C50004     ; Update ports
         RTS

; Update Cursor mode
C33F55:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33F69      ; Branch if so
         JSR C34DE9      ; Forget positions
         LDA #$40        ; Mode: Reset
         TRB $1D4E       ; Set option
         JMP C33D84      ; Redraw options
C33F69:  LDA #$40        ; Mode: Memory
         TSB $1D4E       ; Set option
         JSR C377FC      ; Reset positions
         JMP C33D84      ; Redraw options

; Update Reequip mode
C33F74:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33F85      ; Branch if so
         LDA #$10        ; Mode: Optimum
         TRB $1D4E       ; Set option
         JMP C33DAF      ; Redraw options
C33F85:  LDA #$10        ; Mode: Empty
         TSB $1D4E       ; Set option
         JMP C33DAF      ; Redraw options

; Update Button Settings mode				%%%
C33F8D:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33F9E      ; Branch if so
         LDA #$40        ; Mode: Normal
         TRB $1D54       ; Set option
         JMP C33DDA      ; Redraw options
C33F9E:  LDA #$40        ; Mode: Custom
         TSB $1D54       ; Set option
         JMP C33DDA      ; Redraw options

; Update Controller mode
C33FA6:  JSR C30F0E      ; Sound: Cursor
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C33FB7      ; Branch if so
         LDA #$80        ; Mode: Single
         TRB $1D54       ; Set option
         JMP C33E0B      ; Redraw options
C33FB7:  LDA #$80        ; Mode: Multiple
         TSB $1D54       ; Set option
         JMP C33E0B      ; Redraw options

; Update Mag.Order
C33FBF:  LDA $1D54       ; Game options
         AND #$07        ; Get Mag.Order
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C33FD7      ; Branch if not

; Fork: Mag.Order +1
C33FCC:  LDA $E0         ; Mag.Order
         CMP #$05        ; Rightmost?
         BEQ C33FD6      ; Exit if so
         INC $E0         ; Order +1
         BRA C33FE0      ; Apply changes
C33FD6:  RTS

; Fork: Mag.Order -1
C33FD7:  LDA $E0         ; On "1" now?
         BEQ C33FDF      ; Exit if so
         DEC $E0         ; Order -1
         BRA C33FE0      ; Apply changes
C33FDF:  RTS

; Fork: Apply Mag.Order
C33FE0:  LDA $1D54       ; Game options
         AND #$F8        ; Clear Mag.Order
         ORA $E0         ; Set chosen one
         STA $1D54       ; Save changes
         JMP C3411D      ; Redraw text

; Handle wallpaper selection
C33FED:  LDA $1D4E       ; Game options
         AND #$0F        ; Get wallpaper
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C34005      ; Branch if not

; Fork: Pushing right
C33FFA:  LDA $E0         ; Wallpaper
         CMP #$07        ; Rightmost?
         BEQ C34004      ; Exit if so
         INC $E0         ; Skin number +1
         BRA C3400E      ; Apply changes
C34004:  RTS

; Fork: Pushing left
C34005:  LDA $E0         ; On "1" now?
         BEQ C3400D      ; Exit if so
         DEC $E0         ; Skin number -1
         BRA C3400E      ; Apply changes
C3400D:  RTS

; Fork: Apply wallpaper
C3400E:  LDA $1D4E       ; Game options
         AND #$F0        ; Clear skin
         ORA $E0         ; Set chosen one
         STA $1D4E       ; Save changes
         JSR C341CB      ; Redraw values
         JSR C33B5B      ; Refresh skin
         JMP C342A4      ; Draw RGB info

; Change viewed color in Config
C34021:  LDA $1D54       ; Game options
         AND #$38        ; Viewed color
         LSR A           ; Put in b2-b4
         LSR A           ; Put in b1-b3
         LSR A           ; Now 0-7
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3403C      ; Branch if not

; Fork: Move to next color
C34031:  LDA $E0         ; Viewed color
         CMP #$07        ; Rightmost?
         BEQ C3403B      ; Exit if so
         INC $E0         ; Color number +1
         BRA C34045      ; Apply changes
C3403B:  RTS

; Fork: Move to preceding color
C3403C:  LDA $E0         ; Editing font?
         BEQ C34044      ; Exit if so
         DEC $E0         ; Color number -1
         BRA C34045      ; Apply changes
C34044:  RTS

; Fork: Apply selection
C34045:  LDA $E0         ; Viewed color
         ASL A           ; Put in b1-b3
         ASL A           ; Put in b2-b4
         ASL A           ; Put in b3-b5
         STA $E0         ; Save changes
         LDA $1D54       ; Game options
         AND #$C7        ; Clear vwd color
         ORA $E0         ; Set new one
         STA $1D54       ; Save changes
         JSR C34214      ; Redraw arrow
         JMP C342A4      ; Draw RGB info

; Update red component of font or skin color
C3405C:  JSR C342DF      ; Separate RGB
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3406F      ; Branch if not
         LDA $E2         ; Red
         CMP #$1F        ; 31?
         BEQ C34075      ; Branch if so
         INC $E2         ; Red +1
         BRA C34075      ; Apply changes
C3406F:  LDA $E2         ; Red
         BEQ C34075      ; Branch if 0
         DEC $E2         ; Red -1
C34075:  JSR C34302      ; Merge RGB
         JMP C340E4      ; Apply changes

; Update green component of font or skin color
C3407B:  JSR C342DF      ; Separate RGB
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3408E      ; Branch if not
         LDA $E1         ; Green
         CMP #$1F        ; 31?
         BEQ C34094      ; Branch if so
         INC $E1         ; Green +1
         BRA C34094      ; Apply changes
C3408E:  LDA $E1         ; Green
         BEQ C34094      ; Branch if 0
         DEC $E1         ; Green -1
C34094:  JSR C34302      ; Merge RGB
         JMP C340E4      ; Apply changes

; Update blue component of font or skin color
C3409A:  JSR C342DF      ; Separate RGB
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C340AD      ; Branch if not
         LDA $E0         ; Blue
         CMP #$1F        ; 31?
         BEQ C340B3      ; Branch if so
         INC $E0         ; Blue +1
         BRA C340B3      ; Apply changes
C340AD:  LDA $E0         ; Blue
         BEQ C340B3      ; Branch if 0
         DEC $E0         ; Blue -1
C340B3:  JSR C34302      ; Merge RGB
         JMP C340E4      ; Apply changes

; Apply player's font color
C340B9:  REP #$20        ; 16-bit A
         LDA $1D55       ; User font color
         STA $7E304F     ; Set for FWF
         STA $7E3073     ; Set VWF color A
         STA $7E3077     ; Set VWF color B
         SEP #$20        ; 8-bit A
         RTS

; Apply player's skin colors after changes
C340CD:  LDX $00         ; Dst index: 0
         REP #$20        ; 16-bit A
C340D1:  LDA $1D57,Y     ; Player color
         STA $7E312B,X   ; Put in palette
         INY             ; Src index +1
         INY             ; Src index +1
         INX             ; Dst index +1
         INX             ; Dst index +1
         CPX #$000E      ; Done 7 colors?
         BNE C340D1      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Apply player's skin or font colors after changes
C340E4:  TDC             ; Clear A
         LDA $1D4E       ; Game options
         AND #$0F        ; Get wallpaper
         STA $4202       ; Set multiplicand
         LDA #$0E        ; Palette size
         STA $4203       ; Set multiplier
         LDA $1D54       ; Game options
         AND #$38        ; Viewed color
         BEQ C34112      ; Branch if font
         LSR A           ; Put in b2-b4
         LSR A           ; Put in b1-b3
         CLC             ; Prepare ADC
         ADC $4216       ; Add product
         TAX             ; Index sum
         LDA $9A         ; New color LB
         STA $1D55,X     ; Set as user's
         LDA $9B         ; New color HB
         STA $1D56,X     ; Set as user's
         LDY $4216       ; Palette index
         JSR C340CD      ; Recolor skin
         BRA C3411A      ; Redraw RGB info

; Fork: Font
C34112:  LDY $9A         ; Updated color
         STY $1D55       ; Put in options
         JSR C340B9      ; Put in palettes
C3411A:  JMP C342A4      ; Redraw RGB info

; Draw Mag.Order settings
C3411D:  LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         LDY #C34F7A     ; Text pointer
         JSR C302F9      ; Draw 1-6 in gray
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         TDC             ; Clear A
         LDA $1D54       ; Game options
         AND #$07        ; Get Mag.Order
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3414F,X  ; Tilemap ptr
         STA $F7         ; Set position
         SEP #$20        ; 8-bit A
         LDA $1D54       ; Game options
         AND #$07        ; Get Mag.Order
         CLC             ; ...
         ADC #$54        ; Convert to text		=== SNES: Different base tile number
         STA $F9         ; Add to string
         STZ $FA         ; End string
         JSR C341F7      ; Draw user value
         JMP C3415B      ; Draw spell types

; Tilemap pointers for Mag.Order values
C3414F:  dw $41A5        ; 1
         dw $41A9        ; 2
         dw $41AD        ; 3
         dw $41B1        ; 4
         dw $41B5        ; 5
         dw $41B9        ; 6

; Draw all three Mag.Order spell types
C3415B:  STZ $FD         ; Set terminator		%%% SNES uses the usual string buffer

         TDC             ; Clear A
         LDA $1D54       ; Game options
         AND #$07        ; Get Mag.Order
         ASL A           ; x2
         ASL A           ; x4
         TAX             ; Index it
         LDY #$0003      ; Strings: 3
C34169:  PHY             ; Save counter
         PHX             ; Save index
         JSR C34175      ; Draw string
         PLX             ; String index
         PLY             ; Strings left
         INX             ; Point to next
         DEY             ; One less left
         BNE C34169      ; Loop till last
         RTS

; Draw current Mag.Order spell type

C34175:  LDA.L C341B3,X  ; Text pointer
         TAX             ; Index it


         LDA.L C34FA7,X  ; Letter 1
         STA $F9         ; To string			%%% SNES uses the usual string buffer (same below)
         LDA.L C34FA7+1,X; Letter 2
         STA $FA         ; To string
         LDA.L C34FA7+2,X; Letter 3
         STA $FB         ; To string
         LDA.L C34FA7+3,X; Letter 4
         STA $FC         ; To string











         DEY             ; Lines left -1
         TYA             ; Put it in A
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C341AD,X  ; Tilemap ptr
         STA $F7         ; Set position
         SEP #$20        ; 8-bit A
         LDY #$00F7      ; 00/00F7
         STY $E7         ; Set src LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         JSR C3032C      ; Draw string
         RTS

; Tilemap pointers for Mag.Order strings		=== SNES: +40h as no diacritics
C341AD:  dw $42E9        ; Spell type C
         dw $4269        ; Spell type B
         dw $41E9        ; Spell type A

; Relative pointers to Mag.Order strings		=== SNES: Greater values since longer strings
C341B3:  db $00,$04,$08  ; Healing, Attack, Effect
         db $00          ; ...
         db $00,$08,$04  ; Healing, Effect, Attack
         db $00          ; ...
         db $04,$08,$00  ; Attack, Effect, Healing
         db $00          ; ...
         db $04,$00,$08  ; Attack, Healing, Effect
         db $00          ; ...
         db $08,$00,$04  ; Effect, Healing, Attack
         db $00          ; ...
         db $08,$04,$00  ; Effect, Attack, Healing
         db $00          ; ...

; Draw wallpaper values
C341CB:  LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         LDY #C34F68     ; Text pointer
         JSR C302F9      ; Draw 1-8 in gray
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         TDC             ; Clear A
         LDA $1D4E       ; Game options
         AND #$0F        ; Get wallpaper
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C34204,X  ; Tilemap ptr
         STA $F7         ; Set position
         SEP #$20        ; 8-bit A
         LDA $1D4E       ; Game options
         AND #$0F        ; Get wallpaper
         CLC             ; ...
         ADC #$54        ; Convert to text		=== SNES: Different base tile number
         STA $F9         ; Add to string
         STZ $FA         ; End string
C341F7:  LDY #$00F7      ; 00/00F7
         STY $E7         ; Set src LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw user value
         RTS

; Tilemap pointers for wallpaper values
C34204:  dw $43A5        ; 1
         dw $43A9        ; 2
         dw $43AD        ; 3
         dw $43B1        ; 4
         dw $43B5        ; 5
         dw $43B9        ; 6
         dw $43BD        ; 7
         dw $43C1        ; 8

; Draw wallpaper palette and arrow in Config
C34214:  LDA #$3C        ; Palette 7
         STA $29         ; Set tile info
         LDY #C34F9D     ; Text pointer
         JSR C302F9      ; Draw palette
         LDY #C3427E     ; Text pointer
         JSR C302F9      ; Erase arrow
         TDC             ; Clear A
         LDA $1D54       ; Game options
         AND #$38        ; Viewed color
         BEQ C34252      ; Branch if font
         LSR A           ; Put in b2-b4
         LSR A           ; Put in b1-b3
         TAX             ; Index it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         REP #$20        ; 16-bit A
         LDA.L C3426E,X  ; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw arrow
         LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         JSR C34260      ; Draw "Font"
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JMP C34267      ; Draw "Window"

; Fork: Viewing font
C34252:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C34260      ; Draw "Font"
         LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         JMP C34267      ; Draw "Window"

; Fork: Draw "Font"
C34260:  LDY #C34F88     ; Text pointer
         JSR C302F9      ; Draw "Font"
         RTS

; Fork: Draw "Window"
C34267:  LDY #C34F8F     ; Text pointer
         JSR C30326      ; Draw "Window"
         RTS

; Text pointers for color selection arrow
C3426E:  dw C3427E       ; Font...
         dw C34288       ; Window 1
         dw C3428C       ; Window 2
         dw C34290       ; Window 3
         dw C34294       ; Window 4
         dw C34298       ; Window 5
         dw C3429C       ; Window 6
         dw C342A0       ; Window 7

; Positioned spaces for blanking color selection arrow
C3427E:  dw $44F5 : db "       ",$00

; Positioned arrows for wallpaper colors
C34288:  dw $44F5 : db |↑[end]|   ; Color 1
C3428C:  dw $44F7 : db |↑[end]|   ; Color 2
C34290:  dw $44F9 : db |↑[end]|   ; Color 3
C34294:  dw $44FB : db |↑[end]|   ; Color 4
C34298:  dw $44FD : db |↑[end]|   ; Color 5
C3429C:  dw $44FF : db |↑[end]|   ; Color 6
C342A0:  dw $4501 : db |↑[end]|   ; Color 7

; Draw RGB gauges and values in Config menu
C342A4:  JSR C33A24      ; Reset gauges
         TDC             ; Clear A
         LDA $1D4E       ; Game options
         AND #$0F        ; Get wallpaper
         STA $4202       ; Set multiplicand
         LDA #$0E        ; Palette size
         STA $4203       ; Set multiplier
         LDA $1D54       ; Game options
         AND #$38        ; Viewed color
         BEQ C342C8      ; Branch if font
         LSR A           ; Put in b2-b4
         LSR A           ; Put in b1-b3
         CLC             ; ...
         ADC $4216       ; Add product
         TAX             ; Index sum
         LDY $1D55,X     ; Skin color
         BRA C342CB      ; Skip a line
C342C8:  LDY $1D55       ; Font color
C342CB:  STY $9A         ; Memorize it
         JSR C342DF      ; Separate RGB
         JSR C34344      ; Draw B info
         JSR C342DF      ; Separate RGB
         JSR C34331      ; Draw G info
         JSR C342DF      ; Separate RGB
         JMP C3431E      ; Draw R info

; Separate RGB components for color in Config menu
C342DF:  LDY $9A         ; Color
         STY $E7         ; Memorize it
         LDA $E7         ; Color LB
         AND #$1F        ; Get red
         STA $E2         ; Memorize it
         LDA $E8         ; Color HB
         AND #$7C        ; Get blue
         LSR A           ; Shift bits
         LSR A           ; Now 0-31
         STA $E0         ; Memorize it
         REP #$20        ; 16-bit A
         LDA $E7         ; Color
         AND #$03E0      ; Get green
         LSR A           ; ÷2
         LSR A           ; ÷4
         LSR A           ; ÷8
         LSR A           ; ÷16
         LSR A           ; Now 0-31
         SEP #$20        ; 8-bit A
         STA $E1         ; Memorize it
         RTS

; Merge RGB components of updated color
C34302:  LDA $E0         ; Blue
         ASL A           ; x2
         ASL A           ; x4
         STA $E8         ; Memorize it
         LDA $E2         ; Red
         STA $E7         ; Memorize it
         TDC             ; Clear A
         LDA $E1         ; Green
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         ORA $E7         ; Add R&B
         STA $009A       ; Memorize it
         SEP #$20        ; 8-bit A
         RTS

; Draw value and fill gauge for red component
C3431E:  REP #$20        ; 16-bit A
         LDA #$452F      ; Tilemap ptr
         STA $7E9E89     ; Set gauge pos
         SEP #$20        ; 8-bit A
         LDA $E2         ; Red value
         LDX #$4529      ; Tilemap ptr
         JMP C34357      ; Draw text

; Draw value and fill gauge for green component
C34331:  REP #$20        ; 16-bit A
         LDA #$45AF      ; Tilemap ptr
         STA $7E9E89     ; Set gauge pos
         SEP #$20        ; 8-bit A
         LDA $E1         ; Green value
         LDX #$45A9      ; Tilemap ptr
         JMP C34357      ; Draw text

; Draw value and fill gauge for blue component
C34344:  REP #$20        ; 16-bit A
         LDA #$462F      ; Tilemap ptr
         STA $7E9E89     ; Set gauge pos
         SEP #$20        ; 8-bit A
         LDA $E0         ; Blue value
         LDX #$4629      ; Tilemap ptr
         JMP C34357      ; Draw text

; Draw value and fill gauge for color component
C34357:  PHA             ; Save value
         PHA             ; Do it again
         PHX             ; Save position
         JSR C30563      ; Convert value
         PLX             ; Text position
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C30539      ; Draw 2 digits
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         PLA             ; Color value
         XBA             ; Switch to HB
         LDA $00         ; Clear it
         XBA             ; Switch to LB
         LSR A           ; ÷2
         LSR A           ; ÷4
         TAX             ; Set counter
         BEQ C3437D      ; Branch if 0
C34375:  LDA #$18        ; Full tile char		=== SNES: Different tile number
         STA $2180       ; Add to string
         DEX             ; One less tile
         BNE C34375      ; Loop till last
C3437D:  PLA             ; Color component
         AND #$03        ; Extremity size
         TAX             ; Index it
         LDA.L C3439F,X  ; Partial tile
         STA $2180       ; Add to string
         STZ $2180       ; End string
         LDA #$30        ; Palette 4
         STA $29         ; Color: Gray
         JMP C34392      ; ...
C34392:  LDY #$9E89      ; 7E/9E89
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw gauge
         RTS

; Text characters for filling color gauge		=== SNES: Different tile numbers
C3439F:  db $10          ; Empty tile
         db $12          ; 1/4 full
         db $14          ; 2/4 full
         db $16          ; 3/4 full

; 47: Initialize Cmd.Set menu
C343A3:  JSR C335F7      ; Reset/Stop stuff
         JSR C3450D      ; Draw menu
         JSR C34750      ; Set to shift text
         JSR C34697      ; Load navig data
         JSR C346A0      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$48        ; C3/43C0
         STA $27         ; Queue: Pick char
         JMP C33609      ; BRT:1 + NMI

; 48: Handle Cmd.Set menu member selection
C343C0:  JSR C3469D      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C343F1      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; Selected member
         CMP #$04        ; Chose Arrange?
         BEQ C34407      ; Sort if so
         TAX             ; Index member
         LDA $69,X       ; Nobody there?
         BMI C343EB      ; Fail if so
         JSR C30F1D      ; Sound: Click
         LDA $4E         ; Cursor row
         STA $5E         ; Set return row
         LDA $4B         ; List slot
         STA $64         ; Set member slot
         JSR C346B5      ; Load navig data
         JSR C346BB      ; Relocate cursor
         LDA #$62        ; C3/4419
         STA $26         ; Next: Cmd choice
         RTS

; Fork: Play buzzer
C343EB:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen

; Fork: Handle B and Start
C343F1:  LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BNE C343FD      ; Branch if so
         LDA $09         ; ...
         BIT #$80        ; Pushing B?
         BEQ C34406      ; Exit if not
C343FD:  JSR C30F14      ; Sound: Cursor
         LDA #$0D        ; C3/1CE3
         STA $27         ; Queue Config
         STZ $26         ; Next: Fade-out
C34406:  RTS

; Fork: Reset command order
C34407:  JSR C30F1D      ; Sound: Click
         JSR C30FA4      ; Queue text upload
         JSR C344B1      ; Reset member 1
         JSR C344B9      ; Reset member 2
         JSR C344C2      ; Reset member 3
         JMP C344CB      ; Reset member 4

; 62: Handle Cmd.Set menu command choice 1
C34419:  JSR C346E3      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3443A      ; Branch if not
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; Cursor slot
         STA $28         ; Set blinker's
         JSR C32FA1      ; Create blinker
         LDA #$63        ; C3/4457
         STA $26         ; Next: Choice 2
         TDC             ; Clear A
         LDA $64         ; Selected member
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         STY $67         ; Memorize it
         RTS

; Fork: Handle B
C3443A:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C34456      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         JSR C34697      ; Load navig data
         LDA $5E         ; Return position
         STA $4E         ; Set cursor row
         JSR C346A0      ; Relocate cursor
         LDA $4E         ; ...
         STA $5E         ; ...
         LDA #$48        ; C3/43C0
         STA $26         ; Next: Pick char
         RTS             ; ...
C34456:  RTS

; 63: Handle Cmd.Set menu command choice 2
C34457:  JSR C346E3      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3449E      ; Branch if not
         JSR C30F1D      ; Sound: Click
         TDC             ; Clear A
         LDA $4B         ; Cursor's slot
         REP #$21        ; 16-bit A; C-
         ADC $67         ; Add actor's adr
         TAY             ; Index sum
         PHY             ; Memorize it
         SEP #$20        ; 8-bit A
         LDA $0016,Y     ; Second command
         STA $E0         ; Memorize it
         TDC             ; Clear A
         LDA $28         ; Blinker's slot
         REP #$21        ; 16-bit A; C-
         ADC $67         ; Add actor's adr
         TAY             ; Index sum
         SEP #$20        ; 8-bit A
         LDA $0016,Y     ; First command
         STA $E1         ; Memorize it
         LDA $E0         ; Second command
         STA $0016,Y     ; Replace first
         PLY             ; Point to second
         LDA $E1         ; First command
         STA $0016,Y     ; Replace second
         JSR C34595      ; Draw char 1 text
         JSR C345CE      ; Draw char 2 text
         JSR C34607      ; Draw char 3 text
         JSR C34640      ; Draw char 4 text
         JSR C30FA4      ; Queue text upload
         BRA C344A7      ; Next: Choice 1

; Fork: Handle B
C3449E:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C344B0      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C344A7:  LDA #$05        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$62        ; C3/4419
         STA $26         ; Next: Choice 1
         RTS             ; ...
C344B0:  RTS

; Reset command list for member 1
C344B1:  LDX $00         ; Point to $6D
         JSR C344D4      ; Reset commands
         JMP C34595      ; Redraw text

; Reset command list for member 2
C344B9:  LDX #$0002      ; Point to $6F
         JSR C344D4      ; Reset commands
         JMP C345CE      ; Redraw text

; Reset command list for member 3
C344C2:  LDX #$0004      ; Point to $71
         JSR C344D4      ; Reset commands
         JMP C34607      ; Redraw text

; Reset command list for member 4
C344CB:  LDX #$0006      ; Point to $73
         JSR C344D4      ; Reset commands
         JMP C34640      ; Redraw text

; Reset member's battle command list
C344D4:  LDY $6D,X       ; Actor's address
         BEQ C3450B      ; Exit if nobody
         TDC             ; Clear A
         LDA $0000,Y     ; Actor
         CMP #$0C        ; Gogo?
         BEQ C3450C      ; Exit if so
         STA $4202       ; Set multiplicand
         LDA #$16        ; Actor data size
         STA $4203       ; Set multiplier
         NOP
         NOP
         NOP
         NOP
         LDX $4216       ; Index product
         LDA $ED7CA2,X   ; Command 1
         STA $0016,Y     ; Set actor's
         LDA $ED7CA3,X   ; Command 2
         STA $0017,Y     ; Set actor's
         LDA $ED7CA4,X   ; Command 3
         STA $0018,Y     ; Set actor's
         LDA $ED7CA5,X   ; Command 4
         STA $0019,Y     ; Set actor's
C3450B:  RTS             ; ...
C3450C:  RTS

; Draw Cmd.Set menu
C3450D:  JSR C371BC      ; Clear BG2 map A
         LDY #C34571     ; C3/4571
         JSR C303C4      ; Draw cmd box A
         LDY #C34575     ; C3/4575
         JSR C303C4      ; Draw cmd box B
         LDY #C34579     ; C3/4579
         JSR C303C4      ; Draw cmd box C
         LDY #C3457D     ; C3/457D
         JSR C303C4      ; Draw cmd box D
         LDY #C34581     ; C3/4581
         JSR C303C4      ; Draw name box A
         LDY #C34585     ; C3/4585
         JSR C303C4      ; Draw name box B
         LDY #C34589     ; C3/4589
         JSR C303C4      ; Draw name box C
         LDY #C3458D     ; C3/458D
         JSR C303C4      ; Draw name box D
         LDY #C34591     ; C3/4591
         JSR C303C4      ; Draw Arrange box
         JSR C30EBD      ; Upload windows
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         LDA #$30        ; Palette 4
         STA $29         ; Color: Blue
         LDY #C34FB3     ; Text pointer
         JSR C30326      ; Draw "Arrange"
         JSR C34595      ; Draw char 1 text
         JSR C345CE      ; Draw char 2 text
         JSR C34607      ; Draw char 3 text
         JSR C34640      ; Draw char 4 text
         JSR C30E93      ; Upload BG1 A+B
         JMP C30ED9      ; Upload BG3 A+B

; Window layout for Cmd.Set menu
C34571:  dw $591F,$0412  ; 20x06 at $591F (Command set A)
C34575:  dw $5A9F,$0412  ; 20x06 at $5A9F (Command set B)
C34579:  dw $5C1F,$0412  ; 20x06 at $5C1F (Command set C)
C3457D:  dw $5D9F,$0412  ; 20x06 at $5D9F (Command set D)
C34581:  dw $590B,$0408  ; 10x06 at $590B (Member name A)
C34585:  dw $5A8B,$0408  ; 10x06 at $5A8B (Member name B)
C34589:  dw $5C0B,$0408  ; 10x06 at $5C0B (Member name C)
C3458D:  dw $5D8B,$0408  ; 10x06 at $5D8B (Member name D)
C34591:  dw $588B,$0108  ; 10x03 at $588B (Arrange)

; Draw Cmd.Set menu text for member 1
C34595:  LDA $69         ; Actor in slot
         BMI C345CD      ; Exit if none
         JSL $C20006     ; Load gear data
         LDX $6D         ; Actor's address
         STX $67         ; Memorize it
         LDA #$30        ; Palette 4
         STA $29         ; Color: Blue
         LDY #$794F      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$79CF      ; Text position		=== SNES: +40h as no diacritics
         JSR C33580      ; Draw actor class		=== SNES: No class
         LDY #$796D      ; Text position		=== SNES: +40h as no diacritics (all 4 commands)
         JSR C34679      ; Draw command 1
         LDY #$79E3      ; Text position
         JSR C3467F      ; Draw command 2
         LDY #$79F7      ; Text position
         JSR C34686      ; Draw command 3
         LDY #$7A6D      ; Text position
         JSR C3468E      ; Draw command 4
C345CD:  RTS

; Draw Cmd.Set menu text for member 2
C345CE:  LDA $6A         ; Actor in slot
         BMI C34606      ; Exit if none
         JSL $C20006     ; Load gear data
         LDX $6F         ; Actor's address
         STX $67         ; Memorize it
         LDA #$30        ; Palette 4
         STA $29         ; Color: Blue
         LDY #$7B0F      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7B8F      ; Text position		=== SNES: +40h as no diacritics
         JSR C33580      ; Draw actor class		=== SNES: No class
         LDY #$7B2D      ; Text position		=== SNES: +40h as no diacritics (all 4 commands)
         JSR C34679      ; Draw command 1
         LDY #$7BA3      ; Text position
         JSR C3467F      ; Draw command 2
         LDY #$7BB7      ; Text position
         JSR C34686      ; Draw command 3
         LDY #$7C2D      ; Text position
         JSR C3468E      ; Draw command 4
C34606:  RTS

; Draw Cmd.Set menu text for member 3
C34607:  LDA $6B         ; Actor in slot
         BMI C3463F      ; Exit if none
         JSL $C20006     ; Load gear data
         LDX $71         ; Actor's address
         STX $67         ; Memorize it
         LDA #$30        ; Palette 4
         STA $29         ; Color: Blue
         LDY #$7CCF      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7D4F      ; Text position		=== SNES: +40h as no diacritics
         JSR C33580      ; Draw actor class		=== SNES: No class
         LDY #$7CED      ; Text position		=== SNES: +40h as no diacritics (all 4 commands)
         JSR C34679      ; Draw command 1
         LDY #$7D63      ; Text position
         JSR C3467F      ; Draw command 2
         LDY #$7D77      ; Text position
         JSR C34686      ; Draw command 3
         LDY #$7DED      ; Text position
         JSR C3468E      ; Draw command 4
C3463F:  RTS

; Draw Cmd.Set menu text for member 4
C34640:  LDA $6C         ; Actor in slot
         BMI C34678      ; Exit if none
         JSL $C20006     ; Load gear data
         LDX $73         ; Actor's address
         STX $67         ; Memorize it
         LDA #$30        ; Palette 4
         STA $29         ; Color: Blue
         LDY #$7E8F      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7F0F      ; Text position		=== SNES: +40h as no diacritics
         JSR C33580      ; Draw actor class		=== SNES: No class
         LDY #$7EAD      ; Text position		=== SNES: +40h as no diacritics (all 4 commands)
         JSR C34679      ; Draw command 1
         LDY #$7F23      ; Text position
         JSR C3467F      ; Draw command 2
         LDY #$7F37      ; Text position
         JSR C34686      ; Draw command 3
         LDY #$7FAD      ; Text position
         JSR C3468E      ; Draw command 4
C34678:  RTS

; Draw member's 1st command in Cmd.Set menu
C34679:  JSR C335E1      ; Set pos/WRAM/Y
         JMP C3653E      ; Draw command

; Draw member's 2nd command in Cmd.Set menu
C3467F:  JSR C335E1      ; Set pos/WRAM/Y
         INY             ; Point to cmd 2
         JMP C3653E      ; Draw command

; Draw member's 3rd command in Cmd.Set menu
C34686:  JSR C335E1      ; Set pos/WRAM/Y
         INY             ; Point to cmd 2
         INY             ; Point to cmd 3
         JMP C3653E      ; Draw command

; Draw member's 4th command in Cmd.Set menu
C3468E:  JSR C335E1      ; Set pos/WRAM/Y
         INY             ; Point to cmd 2
         INY             ; Point to cmd 3
         INY             ; Point to cmd 4
         JMP C3653E      ; Draw command

; Load navigation data for Cmd.Set menu's actor list
C34697:  LDY #C346A6     ; C3/46A6
         JMP C30681      ; Load navig data

; Handle D-Pad for Cmd.Set menu's actor list
C3469D:  JSR C307B0      ; Handle D-Pad
C346A0:  LDY #C346AB     ; C3/46AB
         JMP C306C3      ; Relocate cursor

; Navigation data for Cmd.Set menu's actor list
C346A6:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $05          ; 5 rows

; Cursor positions for Cmd.Set menu's actor list
C346AB:  dw $2008        ; Member 1
         dw $5008        ; Member 2
         dw $8008        ; Member 3
         dw $B008        ; Member 4
         dw $0C08        ; Arrange

; Load navigation data for Cmd.Set menu's command list
C346B5:  LDY #C3472B     ; C3/472B
         JMP C30681      ; Load navig data

; Relocate cursor in Cmd.Set menu's command list
C346BB:  TDC             ; Clear A
         LDA $64         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C346C3,X)  ; Relocate cursor

; Jump table for the above
C346C3:  dw C346CB       ; Member 1
         dw C346D1       ; Member 2
         dw C346D7       ; Member 3
         dw C346DD       ; Member 4

; Relocate cursor in Cmd.Set menu's command list for member 1
C346CB:  LDY #C34730     ; C3/4730
         JMP C306C3      ; Relocate cursor

; Relocate cursor in Cmd.Set menu's command list for member 2
C346D1:  LDY #C34738     ; C3/4738
         JMP C306C3      ; Relocate cursor

; Relocate cursor in Cmd.Set menu's command list for member 3
C346D7:  LDY #C34740     ; C3/4740
         JMP C306C3      ; Relocate cursor

; Relocate cursor in Cmd.Set menu's command list for member 4
C346DD:  LDY #C34748     ; C3/4748
         JMP C306C3      ; Relocate cursor

; Handle D-Pad and cursor for Cmd.Set menu's command list
C346E3:  JSR C346F6      ; Handle D-Pad
         TDC             ; Clear A
         LDA $64         ; Member
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C346EE,X)  ; Relocate cursor

; Jump table for the above
C346EE:  dw C346CB       ; Member 1
         dw C346D1       ; Member 2
         dw C346D7       ; Member 3
         dw C346DD       ; Member 4

; Handle D-Pad for Cmd.Set menu's command list
C346F6:  STZ $4D         ; Cursor col: 1st
         LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C34703      ; Branch if not
         STZ $4E         ; Cursor slot: Top
         JSR C30F0E      ; Sound: Cursor
C34703:  LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C34710      ; Branch if not
         LDA #$03        ; Slot: Bottom
         STA $4E         ; Set cursor slot
         JSR C30F0E      ; Sound: Cursor
C34710:  LDA $0B         ; Semi-auto keys
         BIT #$02        ; Pushing left?
         BEQ C3471D      ; Branch if not
         LDA #$01        ; Slot: Left
         STA $4E         ; Set cursor slot
         JSR C30F0E      ; Sound: Cursor
C3471D:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3472A      ; Exit if not
         LDA #$02        ; Slot: Right
         STA $4E         ; Set cursor slot
         JSR C30F0E      ; Sound: Cursor
C3472A:  RTS

; Navigation data for Cmd.Set menu's command list
C3472B:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $04          ; 4 rows

; Cursor positions for member 1 in Cmd.Set menu
C34730:  dw $2080        ; Command 1
         dw $2C58        ; Command 2
         dw $2CA8        ; Command 3
         dw $3880        ; Command 4

; Cursor positions for member 2 in Cmd.Set menu
C34738:  dw $5080        ; Command 1
         dw $5C58        ; Command 2
         dw $5CA8        ; Command 3
         dw $6880        ; Command 4

; Cursor positions for member 3 in Cmd.Set menu
C34740:  dw $8080        ; Command 1
         dw $8C58        ; Command 2
         dw $8CA8        ; Command 3
         dw $9880        ; Command 4

; Cursor positions for member 4 in Cmd.Set menu
C34748:  dw $B080        ; Command 1
         dw $BC58        ; Command 2
         dw $BCA8        ; Command 3
         dw $C880        ; Command 4

; Set to condense text in Cmd.Set menu
C34750:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C3476F     ; C3/476F
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Text shifting table for the above
C3476F:  db $1F,$00,$00  ; Arrange
         db $0C,$04,$00  ; Row 1
         db $0C,$08,$00  ; Row 2
         db $24,$0C,$00  ; Row 3, row 4
         db $0C,$10,$00  ; Row 5
         db $24,$14,$00  ; Row 6, row 7
         db $0C,$18,$00  ; Row 8
         db $24,$1C,$00  ; Row 9, row 10
         db $0C,$20,$00  ; Row 11
         db $24,$24,$00  ; Row 12
         db $00          ; End

; 49: Initialize Button Settings menu			%%%
C3478E:  JSR C335F7      ; Reset/Stop stuff
         JSR C34A2C      ; Draw menu
         JSR C34A84      ; Set to shift text
         JSR C34AD4      ; Load navig data
         JSR C34ADD      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$4A        ; C3/47AB
         STA $27         ; Queue: Sustain
         JMP C33609      ; BRT:1 + NMI

; 4A: Sustain Button Settings menu			%%%
C347AB:  JSR C30FA4      ; Queue BG3 upload
         JSR C34ADA      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BEQ C347CB      ; Branch if not
         JSR C34D7C      ; Valid settings?
         STA $E0         ; ...
         BNE C347DB      ; Fail if not
         JSR C30F1D      ; Sound: Click
         JSR C3ADEF      ; Apply user keys
         LDA #$0D        ; C3/1CE3
         STA $27         ; Queue Config menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle left and right
C347CB:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C347D7      ; Branch if so
         LDA $0B         ; ...
         BIT #$02        ; Pushing left?
         BEQ C347DA      ; Exit if not
C347D7:  JMP C34BF2      ; Handle changes
C347DA:  RTS

; Fork: Invalid combination
C347DB:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; 4B: Initialize Controller menu
C347E2:  JSR C335F7      ; Reset/Stop stuff
         JSR C3482A      ; Draw menu
         JSR C349DD      ; Queue Win2 HDMA
         JSR C34A0C      ; Load navig data
         JSR C34A15      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$4C        ; C3/47FF
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; 4C: Sustain Controller menu
C347FF:  JSR C30FA4      ; Queue BG3 upload
         JSR C34A12      ; Handle D-Pad
         LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BNE C34811      ; Branch if so
         LDA $09         ; ...
         BIT #$80        ; Pushing B?
         BEQ C3481B      ; Branch if not
C34811:  JSR C30F14      ; Sound: Cursor
         LDA #$0D        ; C3/1CE3
         STA $27         ; Queue Config menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle left and right
C3481B:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BNE C34827      ; Branch if so
         LDA $0B         ; ...
         BIT #$02        ; Pushing left?
         BEQ C34829      ; Exit if not
C34827:  BRA C3484C      ; Handle changes
C34829:  RTS

; Draw Controller menu
C3482A:  LDY #C34A28     ; C3/4A28
         JSR C303C4      ; Draw menu window
         JSR C30EBD      ; Upload window
         LDA #$30        ; Palette 4
         STA $29         ; Color: Blue
         LDY #C34FBA     ; Text pointer
         JSR C302F9      ; Draw "Controller"
         JSR C348E9      ; Draw char 1 text
         JSR C34926      ; Draw char 2 text
         JSR C34963      ; Draw char 3 text
         JSR C349A0      ; Draw char 4 text
         JMP C30ED9      ; Upload text

; Handle changes in Controller menu
C3484C:  TDC             ; Clear A
         LDA $4B         ; Member slot
         TAX             ; Index it
         LDA $69,X       ; Nobody there?
         BMI C3485E      ; Exit if so
         JSR C30F0E      ; Sound: Cursor
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C3485F,X)  ; Apply changes
C3485E:  RTS

; Jump table for controller assignments
C3485F:  dw C34867       ; Member 1
         dw C34886       ; Member 2
         dw C348A7       ; Member 3
         dw C348C8       ; Member 4

; Update controller assignment for member 1
C34867:  LDA $1D4F       ; ...
         AND #$01        ; ...
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3487C      ; Branch if not
         LDA #$01        ; Assign Cntlr2
         ORA $1D4F       ; Merge pad data
         STA $1D4F       ; Update options
         BRA C348E9      ; Redraw text
C3487C:  LDA $1D4F       ; Joypad options
         AND #$FE        ; Assign Cntlr1
         STA $1D4F       ; Save changes
         BRA C348E9      ; Redraw text

; Update controller assignment for member 2
C34886:  LDA $1D4F       ; ...
         AND #$02        ; ...
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3489C      ; Branch if not
         LDA #$02        ; Assign Cntlr2
         ORA $1D4F       ; Merge pad data
         STA $1D4F       ; Update options
         JMP C34926      ; Redraw text
C3489C:  LDA $1D4F       ; Joypad options
         AND #$FD        ; Assign Cntlr1
         STA $1D4F       ; Save changes
         JMP C34926      ; Redraw text

; Update controller assignment for member 3
C348A7:  LDA $1D4F       ; ...
         AND #$04        ; ...
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C348BD      ; Branch if not
         LDA #$04        ; Assign Cntlr2
         ORA $1D4F       ; Merge pad data
         STA $1D4F       ; Update options
         JMP C34963      ; Redraw text
C348BD:  LDA $1D4F       ; Joypad options
         AND #$FB        ; Assign Cntlr1
         STA $1D4F       ; Save changes
         JMP C34963      ; Redraw text

; Update controller assignment for member 4
C348C8:  LDA $1D4F       ; ...
         AND #$08        ; ...
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C348DE      ; Branch if not
         LDA #$08        ; Assign Cntlr2
         ORA $1D4F       ; Merge pad data
         STA $1D4F       ; Update options
         JMP C349A0      ; Redraw text
C348DE:  LDA $1D4F       ; Joypad options
         AND #$F7        ; Assign Cntlr1
         STA $1D4F       ; Save changes
         JMP C349A0      ; Redraw text

; Draw Controller menu text for member 1
C348E9:  LDA $69         ; Nobody here?
         BMI C34925      ; Exit if so
         LDX $6D         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7BCF      ; Text position		=== SNES: Fails to do +40h as no diacritics (all members)
         JSR C3356A      ; Draw actor name
         LDA $1D4F       ; Assigned pad
         AND #$01        ; Player 1's?
         BEQ C3490B      ; Branch if so
         LDA #$24        ; Color: Gray
         JSR C34914      ; Draw "Cntlr1"
         LDA #$20        ; Color: User's
         BRA C3491D      ; Draw "Cntlr2"

; Fork: Highlight Cntlr1
C3490B:  LDA #$20        ; Color: User's
         JSR C34914      ; Draw "Cntlr1"
         LDA #$24        ; Color: Gray
         BRA C3491D      ; Draw "Cntlr2"

; Fork: Draw "Cntlr1"
C34914:  STA $29         ; Set palette
         LDY #C34FC9     ; Text pointer
         JSR C302F9      ; Draw "Cntlr1"
         RTS

; Fork: Draw "Cntlr2"
C3491D:  STA $29         ; Set palette
         LDY #C34FD4     ; Text pointer
         JSR C302F9      ; Draw "Cntlr2"
C34925:  RTS

; Draw Controller menu text for member 2
C34926:  LDA $6A         ; Nobody here?
         BMI C34962      ; Exit if so
         LDX $6F         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7C4F      ; Text position
         JSR C3356A      ; Draw actor name
         LDA $1D4F       ; Assigned pad
         AND #$02        ; Player 1's?
         BEQ C34948      ; Branch if so
         LDA #$24        ; Color: Gray
         JSR C34951      ; Draw "Cntlr1"
         LDA #$20        ; Color: User's
         BRA C3495A      ; Draw "Cntlr2"

; Fork: Highlight Cntlr1
C34948:  LDA #$20        ; Color: User's
         JSR C34951      ; Draw "Cntlr1"
         LDA #$24        ; Color: Gray
         BRA C3495A      ; Draw "Cntlr2"

; Fork: Draw "Cntlr1"
C34951:  STA $29         ; Set palette
         LDY #C34FDF     ; Text pointer
         JSR C302F9      ; Draw "Cntlr1"
         RTS

; Fork: Draw "Cntlr2"
C3495A:  STA $29         ; Set palette
         LDY #C34FEA     ; Text pointer
         JSR C302F9      ; Draw "Cntlr2"
C34962:  RTS

; Draw Controller menu text for member 3
C34963:  LDA $6B         ; Nobody here?
         BMI C3499F      ; Exit if so
         LDX $71         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7CCF      ; Text position
         JSR C3356A      ; Draw actor name
         LDA $1D4F       ; Assigned pad
         AND #$04        ; Player 1's?
         BEQ C34985      ; Branch if so
         LDA #$24        ; Color: Gray
         JSR C3498E      ; Draw "Cntlr1"
         LDA #$20        ; Color: User's
         BRA C34997      ; Draw "Cntlr2"

; Fork: Highlight Cntlr1
C34985:  LDA #$20        ; Color: User's
         JSR C3498E      ; Draw "Cntlr1"
         LDA #$24        ; Color: Gray
         BRA C34997      ; Draw "Cntlr2"

; Fork: Draw "Cntlr1"
C3498E:  STA $29         ; Set palette
         LDY #C34FF5     ; Text pointer
         JSR C302F9      ; Draw "Cntlr1"
         RTS

; Fork: Draw "Cntlr2"
C34997:  STA $29         ; Set palette
         LDY #C35000     ; Text pointer
         JSR C302F9      ; Draw "Cntlr2"
C3499F:  RTS

; Draw Controller menu text for member 4
C349A0:  LDA $6C         ; Nobody here?
         BMI C349DC      ; Exit if so
         LDX $73         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7D4F      ; Text position
         JSR C3356A      ; Draw actor name
         LDA $1D4F       ; Assigned pad
         AND #$08        ; Player 1's?
         BEQ C349C2      ; Branch if so
         LDA #$24        ; Color: Gray
         JSR C349CB      ; Draw "Cntlr1"
         LDA #$20        ; Color: User's
         BRA C349D4      ; Draw "Cntlr2"

; Fork: Highlight Cntlr1
C349C2:  LDA #$20        ; Color: User's
         JSR C349CB      ; Draw "Cntlr1"
         LDA #$24        ; Color: Gray
         BRA C349D4      ; Draw "Cntlr2"

; Fork: Draw "Cntlr1"
C349CB:  STA $29         ; Set palette
         LDY #C3500B     ; Text pointer
         JSR C302F9      ; Draw "Cntlr1"
         RTS

; Fork: Draw "Cntlr2"
C349D4:  STA $29         ; Set palette
         LDY #C35016     ; Text pointer
         JSR C302F9      ; Draw "Cntlr2"
C349DC:  RTS

; Set Window 2 positions per scanline for Controller menu
C349DD:  LDA #$01        ; 2Rx1B to PPU
         STA $4350       ; Set DMA mode
         LDA #$28        ; $2128, $2129
         STA $4351       ; To Win 2 L+R
         LDY #C349FC     ; C3/49FC
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Window 2 positions per scanline for Controller menu
C349FC:  db $27,$FF,$FF  ; 255, 255
         db $30,$08,$F7  ; 8, 247
         db $68,$FF,$FF  ; 255, 255
         db $10,$08,$F7  ; 8, 247
         db $10,$FF,$FF  ; 255, 255
         db $00          ; End

; Load navigation data for Controller menu
C34A0C:  LDY #C34A1B     ; C3/4A1B
         JMP C30681      ; Load navig data

; Handle D-Pad for Controller menu
C34A12:  JSR C307B0      ; Handle D-Pad
C34A15:  LDY #C34A20     ; C3/4A20
         JMP C306C3      ; Relocate cursor

; Navigation data for Controller menu
C34A1B:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $04          ; 4 rows

; Cursor positions for Controller menu
C34A20:  dw $7B50        ; Member 1
         dw $8B50        ; Member 2
         dw $9B50        ; Member 3
         dw $AB50        ; Member 4

; Window layout for Controller menu
C34A28:  dw $5B0B,$0B1C  ; 30x13 at $5B0B

; Draw Button Settings menu				%%% Countless functions for this menu follow
C34A2C:  LDY #C34A7C     ; C3/4A7C
         JSR C303C4      ; Draw main box
         LDY #C34A80     ; C3/4A80
         JSR C303C4      ; Draw title box
         JSR C30EBD      ; Upload windows
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C35021     ; Text ptrs loc
         LDY #$0010      ; Strings: 8
         JSR C3714E      ; Draw title, etc.
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C35031     ; Text ptrs loc
         LDY #$000E      ; Strings: 7
         JSR C3712C      ; Draw key names
         JSR C34AF6      ; Draw A options
         JSR C34B22      ; Draw B options
         JSR C34B44      ; Draw X options
         JSR C34B68      ; Draw Y options
         JSR C34B8A      ; Draw L options
         JSR C34BAE      ; Draw R options
         JSR C34BD0      ; Draw S options
         JSR C30E93      ; Upload BG1 A+B
         JMP C30ED9      ; Upload text

; Window layout for Button Settings menu
C34A7C:  dw $590B,$161C  ; 30x24 at $590B (Main)
C34A80:  dw $58B3,$0208  ; 10x04 at $58B3 (Title)

; Set to condense text in Button Settings menu
C34A84:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set CH5 mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C34AA3     ; C3/4AA3
         STY $4352       ; Set CH5 src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set CH5 src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; BG3 text shifting table for Button Settings menu
C34AA3:  db $2F,$00,$00  ; Title, A
         db $0C,$04,$00  ; A's options
         db $0C,$08,$00  ; B
         db $0C,$0C,$00  ; B's options
         db $0C,$10,$00  ; X
         db $0C,$14,$00  ; X's options
         db $0C,$18,$00  ; Y
         db $0C,$1C,$00  ; Y's options
         db $0C,$20,$00  ; L
         db $0C,$24,$00  ; L's options
         db $0C,$28,$00  ; R
         db $0C,$2C,$00  ; R's options
         db $0C,$30,$00  ; Select
         db $0C,$34,$00  ; Select's options
         db $0C,$38,$00  ; Nothing
         db $0C,$3C,$00  ; Nothing
         db $00          ; End

; Load navigation data for Button Settings menu
C34AD4:  LDY #C34AE3     ; C3/4AE3
         JMP C30681      ; Load navig data

; Handle D-Pad for Button Settings menu
C34ADA:  JSR C307B0      ; Handle D-Pad
C34ADD:  LDY #C34AE8     ; C3/4AE8
         JMP C306C3      ; Relocate cursor

; Navigation data for Button Settings menu
C34AE3:  db $00          ; Wraps on all sides
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $07          ; 7 rows

; Cursor positions for Button Settings menu
C34AE8:  dw $2310        ; A
         dw $3B10        ; B
         dw $5310        ; X
         dw $6B10        ; Y
         dw $8310        ; L
         dw $9B10        ; R
         dw $B310        ; Select

; Draw options for A in button settings
C34AF6:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C3503F     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D50       ; Game options
         AND #$F0        ; Action for A
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3503F-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
C34B17:  LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JMP C3032C      ; Draw lit option

; Draw options for B in button settings
C34B22:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C3504B     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D50       ; Game options
         AND #$0F        ; Action for B
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3504B-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         JMP C34B17      ; Draw lit option

; Draw options for X in button settings
C34B44:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C35057     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D51       ; Game options
         AND #$F0        ; Action for X
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C35057-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         JMP C34B17      ; Draw lit option

; Draw options for Y in button settings
C34B68:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C35063     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D51       ; Game options
         AND #$0F        ; Action for Y
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C35063-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         JMP C34B17      ; Draw lit option

; Draw options for L in button settings
C34B8A:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C3506F     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D52       ; Game options
         AND #$F0        ; Action for L
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3506F-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         JMP C34B17      ; Draw lit option

; Draw options for R in button settings
C34BAE:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C3507B     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D52       ; Game options
         AND #$0F        ; Action for R
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3507B-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         JMP C34B17      ; Draw lit option

; Draw options for Select in button settings
C34BD0:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         LDX #C35087     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw all in gray
         TDC             ; Clear A
         LDA $1D53       ; Game options
         AND #$0F        ; Action for SEL...
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C35087-2,X; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         JMP C34B17      ; Draw lit option

; Handle changes in Button Settings menu
C34BF2:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C34BFA,X)  ; Apply changes

; Jump table for the above
C34BFA:  dw C34C08       ; A
         dw C34C44       ; B
         dw C34C74       ; X
         dw C34CB0       ; Y
         dw C34CE0       ; L
         dw C34D1C       ; R
         dw C34D4C       ; Select

; Update action assigned to the A button
C34C08:  LDA $1D50       ; Game options
         AND #$F0        ; Action for A
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         LSR A           ; Now 0-7
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34C24      ; Branch if so

; Fork: Pushing right
C34C19:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34C23      ; Exit if so
         INC $E0         ; Move right
         BRA C34C2F      ; Apply changes
C34C23:  RTS

; Fork: Pushing left
C34C24:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34C2E      ; Exit if so
         DEC $E0         ; Move left
         BRA C34C2F      ; Apply changes
C34C2E:  RTS

; Fork: Apply changes
C34C2F:  LDA $E0         ; Chosen action
         ASL A           ; Put in b1-b4
         ASL A           ; Put in b2-b5
         ASL A           ; Put in b3-b6
         ASL A           ; Put in b4-b7
         STA $E0         ; Save changes
         LDA $1D50       ; Game options
         AND #$0F        ; Clear A action
         ORA $E0         ; Set chosen one
         STA $1D50       ; Save changes
         JMP C34AF6      ; Redraw options

; Update action assigned to the B button
C34C44:  LDA $1D50       ; Game options
         AND #$0F        ; Action for B
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34C5C      ; Branch if so

; Fork: Pushing right
C34C51:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34C5B      ; Exit if so
         INC $E0         ; Move right
         BRA C34C67      ; Apply changes
C34C5B:  RTS

; Fork: Pushing left
C34C5C:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34C66      ; Exit if so
         DEC $E0         ; Move right
         BRA C34C67      ; Apply changes
C34C66:  RTS

; Fork: Apply changes
C34C67:  LDA $1D50       ; Game options
         AND #$F0        ; Clear B action
         ORA $E0         ; Set chosen one
         STA $1D50       ; Save changes
         JMP C34B22      ; Redraw options

; Update action assigned to the X button
C34C74:  LDA $1D51       ; Game options
         AND #$F0        ; Action for X
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         LSR A           ; Now 0-7
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34C90      ; Branch if so

; Fork: Pushing right
C34C85:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34C8F      ; Exit if so
         INC $E0         ; Move right
         BRA C34C9B      ; Apply changes
C34C8F:  RTS

; Fork: Pushing left
C34C90:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34C9A      ; Exit if so
         DEC $E0         ; Move left
         BRA C34C9B      ; Apply changes
C34C9A:  RTS

; Fork: Apply changes
C34C9B:  LDA $E0         ; Chosen action
         ASL A           ; Put in b1-b4
         ASL A           ; Put in b2-b5
         ASL A           ; Put in b3-b6
         ASL A           ; Put in b4-b7
         STA $E0         ; Save changes
         LDA $1D51       ; Game options
         AND #$0F        ; Clear X action
         ORA $E0         ; Set chosen one
         STA $1D51       ; Save changes
         JMP C34B44      ; Redraw options

; Update action assigned to the Y button
C34CB0:  LDA $1D51       ; Game options
         AND #$0F        ; Action for Y
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34CC8      ; Branch if so

; Fork: Pushing right
C34CBD:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34CC7      ; Exit if so
         INC $E0         ; Move right
         BRA C34CD3      ; Apply changes
C34CC7:  RTS

; Fork: Pushing left
C34CC8:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34CD2      ; Exit if so
         DEC $E0         ; Move left
         BRA C34CD3      ; Apply changes
C34CD2:  RTS

; Fork: Apply changes
C34CD3:  LDA $1D51       ; Game options
         AND #$F0        ; Clear Y action
         ORA $E0         ; Set chosen one
         STA $1D51       ; Save changes
         JMP C34B68      ; Redraw options

; Update action assigned to the L button
C34CE0:  LDA $1D52       ; Game options
         AND #$F0        ; Action for L
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         LSR A           ; Now 0-7
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34CFC      ; Branch if so

; Fork: Pushing right
C34CF1:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34CFB      ; Exit if so
         INC $E0         ; Move right
         BRA C34D07      ; Apply changes
C34CFB:  RTS

; Fork: Pushing left
C34CFC:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34D06      ; Exit if so
         DEC $E0         ; Move left
         BRA C34D07      ; Apply changes
C34D06:  RTS

; Fork: Apply changes
C34D07:  LDA $E0         ; Chosen action
         ASL A           ; Put in b1-b4
         ASL A           ; Put in b2-b5
         ASL A           ; Put in b3-b6
         ASL A           ; Put in b4-b7
         STA $E0         ; Save changes
         LDA $1D52       ; Game options
         AND #$0F        ; Clear L action
         ORA $E0         ; Set chosen one
         STA $1D52       ; Save changes
         JMP C34B8A      ; Redraw options

; Update action assigned to the R button
C34D1C:  LDA $1D52       ; Game options
         AND #$0F        ; Action for L
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34D34      ; Branch if so

; Fork: Pushing right
C34D29:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34D33      ; Exit if so
         INC $E0         ; Move right
         BRA C34D3F      ; Apply changes
C34D33:  RTS

; Fork: Pushing left
C34D34:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34D3E      ; Exit if so
         DEC $E0         ; Move left
         BRA C34D3F      ; Apply changes
C34D3E:  RTS

; Fork: Apply changes
C34D3F:  LDA $1D52       ; Game options
         AND #$F0        ; Clear R action
         ORA $E0         ; Set chosen one
         STA $1D52       ; Save changes
         JMP C34BAE      ; Redraw options

; Update action assigned to Select
C34D4C:  LDA $1D53       ; Game options
         AND #$0F        ; Action for SEL
         STA $E0         ; Memorize it
         LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing left?
         BEQ C34D64      ; Branch if so

; Fork: Pushing right
C34D59:  LDA $E0         ; Lit option
         CMP #$06        ; Rightmost?
         BEQ C34D63      ; Exit if so
         INC $E0         ; Move right
         BRA C34D6F      ; Apply changes
C34D63:  RTS

; Fork: Pushing left
C34D64:  LDA $E0         ; Lit option
         CMP #$01        ; Leftmost?
         BEQ C34D6E      ; Exit if so
         DEC $E0         ; Move left
         BRA C34D6F      ; Apply changes
C34D6E:  RTS

; Fork: Apply changes
C34D6F:  LDA $1D53       ; Game options
         AND #$F0        ; Clear SEL action
         ORA $E0         ; Set chosen one
         STA $1D53       ; Save changes
         JMP C34BD0      ; Redraw options

; Validate changes made in Button Settings menu
C34D7C:  LDA $1D50       ; Game options
         AND #$0F        ; Action for B
         STA $7E9D89     ; Add to buffer
         LDA $1D50       ; Game options
         AND #$F0        ; Action for A
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         LSR A           ; Now 0-7
         STA $7E9D8A     ; Add to buffer
         LDA $1D51       ; Game options
         AND #$0F        ; Action for Y
         STA $7E9D8B     ; Add to buffer
         LDA $1D51       ; Game options
         AND #$F0        ; Action for X
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         LSR A           ; Now 0-7
         STA $7E9D8C     ; Add to buffer
         LDA $1D52       ; Game options
         AND #$0F        ; Action for R
         STA $7E9D8D     ; Add to buffer
         LDA $1D52       ; Game options
         AND #$F0        ; Action for L
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         LSR A           ; Now 0-7
         STA $7E9D8E     ; Add to buffer
         LDA $1D53       ; Game options
         AND #$0F        ; Action for SEL
         STA $7E9D8F     ; Add to buffer

; Fork: Check if all actions are assigned
C34DC7:  LDA #$01        ; 1st: Confirm
         STA $E0         ; Set cur action
         LDY $00         ; Actions done: 0

; Fork: Check if current action is assigned
C34DCD:  LDX $00         ; 1st key: A
C34DCF:  LDA $7E9D89,X   ; Key's action
         CMP $E0         ; Matches ours?
         BEQ C34DDF      ; Branch if so
         INX             ; Key index +1
         CPX #$0007      ; Done all 7?
         BNE C34DCF      ; Loop if not
         TXA             ; Valid: N
         RTS

; Fork: Check next action
C34DDF:  INC $E0         ; Action num +1
         INY             ; One more done
         CPY #$0006      ; Done all 6?
         BNE C34DCD      ; Loop if not
         TDC             ; Valid: Y
         RTS

; Forget memorized cursor positions for main menu
C34DE9:  TDC             ; Clear A
         TAX             ; Index: 0
C34DEB:  STA $022B,X     ; Clear position
         INX             ; Index +1
         CPX #$001F      ; At $024A?
         BNE C34DEB      ; Loop if not
         RTS

; Text pointers for Config page 1
C34DF5:  dw C34DFD                       ; Controller
         dw C34E78                       ; Cursor
C34DF9:  dw C34E0E                       ; Fast
         dw C34E14                       ; Slow

; Positioned text for Config page 1
C34DFD:  dw $3D8F : db |コントローラー[end]|	 ; Controller
C34E07:  dw $39B5 : db |ウェイト[end]|	 ; Wait
C34E0E:  dw $3A65 : db |はやい[end]|	 ; Fast
C34E14:  dw $3A75 : db |おそい[end]|	 ; Slow
C34E1A:  dw $3B35 : db |たんしゅく[end]|	 ; Short
C34E22:  dw $3BA5 : db |オン[end]|  	 ; On
C34E27:  dw $3BB5 : db |オフ[end]|	 ; Off
C34E2C:  dw $3C25 : db |ステレオ[end]|	 ; Stereo
C34E33:  dw $3C35 : db |モノラル[end]|	 ; Mono
C34E3A:  dw $3CB5 : db |きおく[end]|	 ; Memory
C34E40:  dw $3D25 : db |さいきょう[end]|	 ; Optimum
C34E48:  dw $3DA5 : db |ノーマル[end]|	 ; Normal		%%%
C34E4F:  dw $3DB5 : db |カスタム[end]|	 ; Custom		%%%
C34E56:  dw $3E35 : db |マルチ[end]|	 ; Multiple		=== SNES: Moved higher as no Button Settings menu
C34E5C:  dw $3A25 : db "1 2 3 4 5 6",$00
C34E6A:  dw $3AA5 : db "1 2 3 4 5 6",$00
C34E78:  dw $3C8F : db |カーソルいち[end]|	 ; Cursor

; Text pointers for Config page 1
C34E81:  dw C34E97                       ; Bat.Mode
         dw C34EA0                       ; Bat.Speed
         dw C34EA7                       ; Msg.Speed
         dw C34EAF                       ; Cmd.Set
         dw C34EB9                       ; Gauge
         dw C34EBF                       ; Sound
         dw C34EC6                       ; Reequip

; Positioned text for Config page 1				=== SNES: All positions differ (most are +40h as no diacritics)
C34E8F:  dw $78BB : db |コンフィグ[end]|	 ; Config
C34E97:  dw $394F : db |バトルモード[end]|	 ; Bat.Mode
C34EA0:  dw $39D3 : db |スピード[end]|	 ; Bat.Speed
C34EA7:  dw $3A53 : db |メッセージ[end]|	 ; Msg.Speed
C34EAF:  dw $3AD3 : db |コマンドしてい[end]|	 ; Cmd.Set
C34EB9:  dw $3B53 : db |ゲージ[end]|	 ; Gauge
C34EBF:  dw $3BCF : db |サウンド[end]|	 ; Sound
C34EC6:  dw $3CCF : db |さいそうび[end]|	 ; Reequip
C34ECE:  dw $3965 : db |アクティヴ[end]|	 ; Active
C34ED6:  dw $3AE5 : db |ウィンドウ[end]|	 ; Window
C34EDE:  dw $3C65 : db |もどす[end]|	 ; Reset
C34EE4:  dw $3CF5 : db |すべてはずす[end]|	 ; Empty
C34EED:  dw $3DE5 : db |シングル[end]|	 ; Single

; Text pointers for Config page 2
C34EF4:  dw C34F0C                       ; Mag.Order
         dw C34F18                       ; Window
         dw C34F20                       ; Color
C34EFA:  dw C34F35                       ; «========»
         dw C34F42                       ; «========»
         dw C34F4F                       ; «========»
C34F00:  dw C34F5C                       ; R
         dw C34F60                       ; G
         dw C34F64                       ; B
         dw C34F26                       ; 1‥
         dw C34F2B                       ; 2‥
         dw C34F30                       ; 3‥

; Positioned text for Config page 2
C34F0C:  dw $414F : db |まほうのならびかた[end]|	 ; Mag.Order		=== SNES: +40h as no diacritics (also next two strings)
C34F18:  dw $434F : db |ウィンドウ[end]|	 ; Window
C34F20:  dw $43CF : db |カラー[end]|	 ; Color
C34F26:  dw $4225 : db |１‥[end]|				=== SNES uses letters
C34F2B:  dw $42A5 : db |２‥[end]|
C34F30:  dw $4325 : db |３‥[end]|
C34F35:  dw $452D : db "«±±±±±±±±»",$00
C34F42:  dw $45AD : db "«±±±±±±±±»",$00
C34F4F:  dw $462D : db "«±±±±±±±±»",$00
C34F5C:  dw $4525 : db "R",$00
C34F60:  dw $45A5 : db "G",$00
C34F64:  dw $4625 : db "B",$00
C34F68:  dw $43A5 : db "1 2 3 4 5 6 7 8",$00
C34F7A:  dw $41A5 : db "1 2 3 4 5 6",$00
C34F88:  dw $4425 : db |フォント[end]|	 ; Font
C34F8F:  dw $43F5 : db |ウィンドウ[end]|	 ; Window		=== SNES: +40h as no diacritics
C34F97:  dw $43FB : db |もどす[end]|	 ; Restore (unused)
C34F9D:  dw $44B5 : db !pal1,!pal2,!pal3,!pal4,!pal5,!pal6,!pal7,$00

; Mag.Order strings
C34FA7:  db |かいふく|				; Healing	=== SNES adds icons
C34FAB:  db |こうげき|				; Attack
C34FAF:  db |かんせつ|				; Effect

; Positioned text for Cmd.Set menu
C34FB3:  dw $788F : db |せいとん[end]|		; Arrange	=== SNES: +40h as no diacritics

; Positioned text for Controller menu
C34FBA:  dw $7B4D : db |コントローラーのわりふり[end]|	; Controller
C34FC9:  dw $7C21 : db |コントローラー１[end]|		; Cntlr1
C34FD4:  dw $7C33 : db |コントローラー２[end]|		; Cntlr2
C34FDF:  dw $7CA1 : db |コントローラー１[end]|		; Cntlr1
C34FEA:  dw $7CB3 : db |コントローラー２[end]|		; Cntlr2
C34FF5:  dw $7D21 : db |コントローラー１[end]|		; Cntlr1
C35000:  dw $7D33 : db |コントローラー２[end]|		; Cntlr2
C3500B:  dw $7DA1 : db |コントローラー１[end]|		; Cntlr1
C35016:  dw $7DB3 : db |コントローラー２[end]|		; Cntlr2

; Text pointers for Button Settings menu			%%%
C35021:  dw C35093             			; Button Settings
         dw C351CB             			; A: button
         dw C351D1            			; B: button
         dw C351D7         			; X: button
         dw C351DD           			; Y: button
         dw C351E3          			; L: button
         dw C351E9            			; R: button
         dw C351EF          			; S: button
C35031:  dw C351F5      			; A
         dw C351F9         			; B
         dw C351FD          			; X
         dw C35201              		; Y
         dw C35205             			; L
         dw C35209                  		; R
         dw C3520D               		; SEL
C3503F:  dw C3509E                  		; A: Decision
         dw C350A5                      	; A: Cancel
         dw C350AC                      	; A: Menu
         dw C350B3                      	; A: Party
         dw C350BB                      	; A: Change
         dw C350C2                      	; A: Defense
C3504B:  dw C350C9                      	; B: Decision
         dw C350D0                      	; B: Cancel
         dw C350D7                      	; B: Menu
         dw C350DE                      	; B: Party
         dw C350E6                      	; B: Change
         dw C350ED                      	; B: Defense
C35057:  dw C350F4                      	; X: Decision
         dw C350FB                      	; X: Cancel
         dw C35102                      	; X: Menu
         dw C35109                      	; X: Party
         dw C35111                      	; X: Change
         dw C35118                      	; X: Defense
C35063:  dw C3511F                      	; Y: Decision
         dw C35126                      	; Y: Cancel
         dw C3512D                      	; Y: Menu
         dw C35134                      	; Y: Party
         dw C3513C                      	; Y: Change
         dw C35143                      	; Y: Defense
C3506F:  dw C3514A                      	; L: Decision
         dw C35151                      	; L: Cancel
         dw C35158                      	; L: Menu
         dw C3515F                      	; L: Party
         dw C35167                      	; L: Change
         dw C3516E                      	; L: Defense
C3507B:  dw C35175                      	; R: Decision
         dw C3517C                      	; R: Cancel
         dw C35183                      	; R: Menu
         dw C3518A                      	; R: Party
         dw C35192                      	; R: Change
         dw C35199                      	; R: Defense
C35087:  dw C351A0                      	; S: Decision
         dw C351A7                      	; S: Cancel
         dw C351AE                      	; S: Menu
         dw C351B5                      	; S: Party
         dw C351BD                      	; S: Change
         dw C351C4                      	; S: Defense

; Positioned text for Button Settings menu			%%%
C35093:  dw $78F5 : db |ボタンのせってい[end]|		; Button Settings
C3509E:  dw $79CD : db |けってい[end]|		; A: Decision
C350A5:  dw $79D7 : db |ちゅうし[end]|		; A: Cancel
C350AC:  dw $79E1 : db |メニュー[end]|		; A: Menu
C350B3:  dw $79E9 : db |パーティー[end]|		; A: Party
C350BB:  dw $79F3 : db |チェンジ[end]|		; A: Change
C350C2:  dw $79FD : db |ぼうぎょ[end]|		; A: Defense
C350C9:  dw $7ACD : db |けってい[end]|		; B: Decision
C350D0:  dw $7AD7 : db |ちゅうし[end]|		; B: Cancel
C350D7:  dw $7AE1 : db |メニュー[end]|		; B: Menu
C350DE:  dw $7AE9 : db |パーティー[end]|		; B: Party
C350E6:  dw $7AF3 : db |チェンジ[end]|		; B: Change
C350ED:  dw $7AFD : db |ぼうぎょ[end]|		; B: Defense
C350F4:  dw $7BCD : db |けってい[end]|		; X: Decision
C350FB:  dw $7BD7 : db |ちゅうし[end]|		; X: Cancel
C35102:  dw $7BE1 : db |メニュー[end]|		; X: Menu
C35109:  dw $7BE9 : db |パーティー[end]|		; X: Party
C35111:  dw $7BF3 : db |チェンジ[end]|		; X: Change
C35118:  dw $7BFD : db |ぼうぎょ[end]|		; X: Defense
C3511F:  dw $7CCD : db |けってい[end]|		; Y: Decision
C35126:  dw $7CD7 : db |ちゅうし[end]|		; Y: Cancel
C3512D:  dw $7CE1 : db |メニュー[end]|		; Y: Menu
C35134:  dw $7CE9 : db |パーティー[end]|		; Y: Party
C3513C:  dw $7CF3 : db |チェンジ[end]|		; Y: Change
C35143:  dw $7CFD : db |ぼうぎょ[end]|		; Y: Defense
C3514A:  dw $7DCD : db |けってい[end]|		; L: Decision
C35151:  dw $7DD7 : db |ちゅうし[end]|		; L: Cancel
C35158:  dw $7DE1 : db |メニュー[end]|		; L: Menu
C3515F:  dw $7DE9 : db |パーティー[end]|		; L: Party
C35167:  dw $7DF3 : db |チェンジ[end]|		; L: Change
C3516E:  dw $7DFD : db |ぼうぎょ[end]|		; L: Defense
C35175:  dw $7ECD : db |けってい[end]|		; R: Decision
C3517C:  dw $7ED7 : db |ちゅうし[end]|		; R: Cancel
C35183:  dw $7EE1 : db |メニュー[end]|		; R: Menu
C3518A:  dw $7EE9 : db |パーティー[end]|		; R: Party
C35192:  dw $7EF3 : db |チェンジ[end]|		; R: Change
C35199:  dw $7EFD : db |ぼうぎょ[end]|		; R: Defense
C351A0:  dw $7FCD : db |けってい[end]|		; S: Decision
C351A7:  dw $7FD7 : db |ちゅうし[end]|		; S: Cancel
C351AE:  dw $7FE1 : db |メニュー[end]|		; S: Menu
C351B5:  dw $7FE9 : db |パーティー[end]|		; S: Party
C351BD:  dw $7FF3 : db |チェンジ[end]|		; S: Change
C351C4:  dw $7FFD : db |ぼうぎょ[end]|		; S: Defense
C351CB:  dw $7953 : db |ボタン[end]|		; A: button
C351D1:  dw $7A53 : db |ボタン[end]|		; B: button
C351D7:  dw $7B53 : db |ボタン[end]|		; X: button
C351DD:  dw $7C53 : db |ボタン[end]|		; Y: button
C351E3:  dw $7D53 : db |ボタン[end]|		; L: button
C351E9:  dw $7E53 : db |ボタン[end]|		; R: button
C351EF:  dw $7F57 : db |ボタン[end]|		; S: button
C351F5:  dw $7991 : db "A",$00
C351F9:  dw $7A91 : db "B",$00
C351FD:  dw $7B91 : db "X",$00
C35201:  dw $7C91 : db "Y",$00
C35205:  dw $7D91 : db "L",$00
C35209:  dw $7E91 : db "R",$00
C3520D:  dw $7F91 : db "SEL",$00

; Load navigation data for Skills menu
C35213:  LDY #C35232     ; C3/5232
         JMP C30681      ; Load navig data

; Handle D-Pad and cursor memory for Skills menu
C35219:  JSR C307B0      ; Handle D-Pad
C3521C:  LDY #C35237     ; C3/5237
         JSR C306C3      ; Relocate cursor
         TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $4D         ; Cursor column
         STA $0236,X     ; Remember it
         LDA $4E         ; Cursor row
         STA $0237,X     ; Remember it
         RTS

; Navigation data for Skills menu
C35232:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $01          ; Initial row
         db $01          ; 1 column
         db $07          ; 7 rows

; Cursor positions for Skills menu
C35237:  dw $1400        ; Espers
         dw $2400        ; Magic
         dw $4400        ; SwdTech
         dw $5400        ; Blitz
         dw $6400        ; Lore
         dw $7400        ; Rage
         dw $8400        ; Dance

; Load navigation data for Magic menu
C35245:  LDY #C3526C     ; C3/526C
         JMP C30681      ; Load navig data

; Handle D-Pad and cursor memory for Magic menu
C3524B:  JSR C38948      ; Handle D-Pad
C3524E:  LDY #C35271     ; C3/5271
         JSR C306CB      ; Relocate cursor
         TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $4F         ; List column
         STA $023E,X     ; Remember it
         LDA $50         ; List row
         STA $023F,X     ; Remember it
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $4A         ; Scroll position
         STA $0246,X     ; Remember it
         RTS

; Navigation data for Magic menu
C3526C:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $03          ; 3 columns			=== SNES: 2
         db $09          ; 9 rows			=== SNES: 8

; Cursor positions for Magic menu
C35271:  dw $6808        ; Spell 1			=== SNES: All positions differ
         dw $6850        ; Spell 2
         dw $6898        ; Spell 3
         dw $7408        ; Spell 4
         dw $7450        ; Spell 5
         dw $7498        ; Spell 6
         dw $8008        ; Spell 7
         dw $8050        ; Spell 8
         dw $8098        ; Spell 9
         dw $8C08        ; Spell 10
         dw $8C50        ; Spell 11
         dw $8C98        ; Spell 12
         dw $9808        ; Spell 13
         dw $9850        ; Spell 14
         dw $9898        ; Spell 15
         dw $A408        ; Spell 16
         dw $A450        ; Spell 17			%%%
         dw $A498        ; Spell 18
         dw $B008        ; Spell 19
         dw $B050        ; Spell 20
         dw $B098        ; Spell 21
         dw $BC08        ; Spell 22
         dw $BC50        ; Spell 23
         dw $BC98        ; Spell 24
         dw $C808        ; Spell 25
         dw $C850        ; Spell 26
         dw $C898        ; Spell 27

; Load navigation data for SwdTech, Blitz, or Dance menu
C352A7:  LDY #C352B8     ; C3/52B8
         JMP C30681      ; Load navig data

; Handle D-Pad for SwdTech, Blitz, or Dance menu
C352AD:  JSR C307B0      ; Handle D-Pad
C352B0:  LDY #C352BD     ; C3/52BD
         STY $E7         ; ...
         JMP C306C3      ; Relocate cursor

; Navigation data for SwdTech, Blitz, and Dance menus
C352B8:  db $00          ; Wraps on all sides
         db $00          ; Initial column
         db $00          ; Initial row
         db $02          ; 2 columns
         db $04          ; 4 rows

; Cursor positions for SwdTech, Blitz, and Dance menus
C352BD:  dw $7418        ; Skill 1			=== SNES: All are shifted leftward
         dw $7488        ; Skill 2
         dw $8C18        ; Skill 3
         dw $8C88        ; Skill 4
         dw $A418        ; Skill 5
         dw $A488        ; Skill 6
         dw $BC18        ; Skill 7
         dw $BC88        ; Skill 8

; Load navigation data for Lore or Espers menu		=== SNES: Lore only
C352CD:  LDY #C352DC     ; C3/52DC
         JMP C30681      ; Load navig data

; Handle D-Pad for Lore or Espers menu			=== SNES: Lore only
C352D3:  JSR C38948      ; Handle D-Pad
C352D6:  LDY #C352E1     ; C3/52E1
         JMP C306CB      ; Relocate cursor

; Navigation data for Lore and Espers menus		=== SNES: Lore only
C352DC:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $02          ; 2 columns			=== SNES: 1
         db $09          ; 9 rows			=== SNES: 8

; Cursor positions for Lore and Espers menus		=== SNES: Lore only
C352E1:  dw $6808        ; Skill 1			=== SNES: All are shifted downward (taller description window)
         dw $6878        ; Skill 2
         dw $7408        ; Skill 3
         dw $7478        ; Skill 4
         dw $8008        ; Skill 5
         dw $8078        ; Skill 6
         dw $8C08        ; Skill 7
         dw $8C78        ; Skill 8
         dw $9808        ; Skill 9			%%%
         dw $9878        ; Skill 10
         dw $A408        ; Skill 11
         dw $A478        ; Skill 12
         dw $B008        ; Skill 13
         dw $B078        ; Skill 14
         dw $BC08        ; Skill 15
         dw $BC78        ; Skill 16
         dw $C808        ; Skill 17
         dw $C878        ; Skill 18



































; Load navigation data for Rage menu
C35305:  LDY #C35314     ; C3/5314
         JMP C30681      ; Load navig data

; Handle D-Pad for Rage menu
C3530B:  JSR C38948      ; Handle D-Pad
C3530E:  LDY #C35319     ; C3/5319
         JMP C306CB      ; Relocate cursor

; Navigation data for Rage menu
C35314:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $02          ; 2 columns
         db $09          ; 9 rows			=== SNES: 8

; Cursor positions for Rage menu
C35319:  dw $6818        ; Rage 1			=== SNES: All are shifted downward (taller description window)
         dw $6888        ; Rage 2
         dw $7418        ; Rage 3
         dw $7488        ; Rage 4
         dw $8018        ; Rage 5
         dw $8088        ; Rage 6
         dw $8C18        ; Rage 7
         dw $8C88        ; Rage 8
         dw $9818        ; Rage 9
         dw $9888        ; Rage 10
         dw $A418        ; Rage 11
         dw $A488        ; Rage 12
         dw $B018        ; Rage 13
         dw $B088        ; Rage 14
         dw $BC18        ; Rage 15
         dw $BC88        ; Rage 16
         dw $C818        ; Rage 17			%%%
         dw $C888        ; Rage 18

; Draw Skills menu, disable individual MP costs in Magic menu
C3533D:  STZ $9E         ; No MP by Magic
         JSR C30FF4      ; Stop VRAM DMA B
         LDA #$01        ; 64x32 at $0000
         STA $2107       ; Set BG1 map loc
         JSR C371BC      ; Clear BG2 map A
         JSR C371C1      ; Clear BG2 map B
         LDY #C3546A     ; C3/546A
         JSR C303C4      ; Draw lower box A
         LDY #C35466     ; C3/5466
         JSR C303C4      ; Draw stats box A
         LDY #C3546E     ; C3/546E
         JSR C303C4      ; Draw top box A
         LDY #C35462     ; C3/5462
         JSR C303C4      ; Draw option box B
         LDY #C3545E     ; C3/545E
         JSR C303C4      ; Draw option box A
         LDY #C35476     ; C3/5476
         JSR C303C4      ; Draw lower box B
         LDY #C35472     ; C3/5472
         JSR C303C4      ; Draw stats box B
         LDY #C3547E     ; C3/547E
         JSR C303C4      ; Draw top box B
         LDY #C3547A     ; C3/547A
         JSR C303C4      ; Draw title box
         JSR C30EBD      ; Upload windows
         JSR C353E7      ; Draw actor info
         JSR C30E93      ; Upload BG1 A+B
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         JSR C371DA      ; Clear BG3 map C
         JSR C3AFC5      ; Build desc map
         JSR C3AE9A      ; Upload tech names		%%%
         JSR C353FD      ; Set skill colors
         LDA $79         ; Espers palette
         STA $29         ; Set attributes
         LDY #C362A0     ; Text pointer
         JSR C30326      ; Draw "Espers"
         LDA $7A         ; Magic palette
         STA $29         ; Set attributes
         LDY #C362A8     ; Text pointer
         JSR C30326      ; Draw "Magic"
         LDA $7B         ; SwdTech palette
         STA $29         ; Set attributes
         LDY #C362AE     ; Text pointer
         JSR C30326      ; Draw "SwdTech"
         LDA $7C         ; Blitz palette
         STA $29         ; Set attributes
         LDY #C362B7     ; Text pointer
         JSR C30326      ; Draw "Blitz"
         LDA $7D         ; Lore palette
         STA $29         ; Set attributes
         LDY #C362C0     ; Text pointer
         JSR C30326      ; Draw "Lore"
         LDA $7E         ; Rage palette
         STA $29         ; Set attributes
         LDY #C362C9     ; Text pointer
         JSR C30326      ; Draw "Rage"
         LDA $7F         ; Dance palette
         STA $29         ; Set attributes
         LDY #C362D0     ; Text pointer
         JSR C30326      ; Draw "Dance"
         JMP C30ED9      ; Upload BG3 A+B

; Draw actor info in Skills menu, including blue text
C353E7:  JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C362D6     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         JMP C355B4      ; Draw actor info

; Assign a palette to each submenu in Skills menu
C353FD:  LDA #$24        ; Gray palette
         LDX $00         ; 1st: Espers
C35401:  STA $79,X       ; Disable menu
         INX             ; Menu slot +1
         CPX #$0007      ; Done Dance?
         BNE C35401      ; Loop if not
         JSR C355AC      ; Actor's address
         PHY             ; Memorize it
         LDX #$0004      ; Commands: 4
C35410:  PHX             ; Save counter
         LDX $00         ; 1st: Espers
C35413:  LDA $0016,Y     ; Actor's command
         CMP.L C35438,X  ; Unlocks submenu?
         BNE C35420      ; Skip menu if not
         LDA #$20        ; Color: User's
         STA $79,X       ; Enable menu
C35420:  INX             ; Menu slot +1
         CPX #$0007      ; Done Dance?
         BNE C35413      ; Loop if not
         INY             ; Cmd slot +1
         PLX             ; Loop counter
         DEX             ; One less cmd
         BNE C35410      ; Loop till last
         PLY             ; Actor's address
         LDA $0000,Y     ; Actor
         CMP #$0C        ; Gogo?
         BNE C35437      ; Exit if not
         LDA #$24        ; Gray palette
         STA $79         ; Disable Espers
C35437:  RTS

; Battle commands that unlock a skill menu
C35438:  db $02          ; Magic (unlocks Espers)
         db $02          ; Magic (unlocks Magic)
         db $07          ; SwdTech
         db $0A          ; Blitz
         db $0C          ; Lore
         db $10          ; Rage
         db $13          ; Dance

; Draw Magic list and blue "MP.." and create portrait		=== SNES: "…"
C3543F:  JSR C371A9      ; Clear BG1 map A
         JSR C355EB      ; Build spell list
         JSR C35659      ; Draw spell list
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C362DC     ; Text pointer
         JSR C302F9      ; Erase title diac.			%%%
         LDY #C362E5     ; Text pointer
         JSR C302F9      ; Draw "MP.."				=== SNES: "…"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload

; Window layout for main Skills menu
C3545E:  dw $588B,$0406  ; 08x06 at $588B (Upper submenus)	=== SNES: Expanded rightward
C35462:  dw $5A0B,$0A06  ; 08x12 at $5A0B (Lower submenus)	=== SNES: Expanded rightward
C35466:  dw $598B,$051C  ; 30x07 at $598B (Stats)		=== SNES: Shifted downward (taller description window)
C3546A:  dw $5B4B,$0D1C  ; 30x15 at $5B4B (Bottom)		=== SNES: Shifted downward
C3546E:  dw $589B,$0214  ; 22x04 at $589B (Top)			=== SNES: Taller and wider

; Window layout for Skills submenus
C35472:  dw $618B,$051C  ; 30x07 at $618B (Stats)		=== SNES: Shifted downward
C35476:  dw $634B,$0D1C  ; 30x15 at $634B (List)		=== SNES: Wider; shifted downward
C3547A:  dw $608B,$0206  ; 08x04 at $608B (Title)		=== SNES: Opposite corner; wider but shorter
C3547E:  dw $609B,$0214  ; 22x04 at $609B (Description)		=== SNES: Taller and wider

; Set to condense text in Skills menu or submenu
C35482:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set CH5 mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C354EC     ; C3/54EC
         STY $4352       ; Set CH5 src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set CH5 src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         JSR C354F3      ; Load BG1 V-Data
         LDX $00         ; Index: 0
C354A5:  LDA.L C35538,X  ; BG1 H-Pan data
         STA $7E9A09,X   ; Save in RAM
         INX             ; Index +1
         CPX #$000D      ; End of table?
         BNE C354A5      ; Loop if not
         LDA #$02        ; 1Rx2B to PPU
         STA $4360       ; Set CH6 mode
         LDA #$0D        ; $210D
         STA $4361       ; To BG1 H-Scroll
         LDY #$9A09      ; 7E/9A09
         STY $4362       ; Set CH6 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4364       ; Set CH6 src HB
         LDA #$7E        ; ...
         STA $4367       ; Set indir HB
         LDA #$02        ; 1Rx2B to PPU
         STA $4370       ; Set CH7 mode
         LDA #$0E        ; $210E
         STA $4371       ; To BG1 V-Scroll
         LDY #$9849      ; 7E/9849
         STY $4372       ; Set CH7 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4374       ; Set CH7 src HB
         LDA #$7E        ; ...
         STA $4377       ; Set indir HB
         LDA #$C0        ; Channels: 6, 7
         TSB $43         ; Queue HDMA 6+7
         RTS

; BG3 vertical shift table for skill menus
C354EC:  db $4F,$02,$00  ; SwdTech and above
         db $40,$02,$00  ; Blitz and below
         db $00          ; End

; Load vertical shift values for BG1 text in skill menus
C354F3:  LDX $00         ; Index: 0
C354F5:  LDA.L C35545,X  ; Stats V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         CPX #$0012      ; At skills?
         BNE C354F5      ; Loop if not
C35503:  LDA.L C35545,X  ; Skill V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         TDC             ; Clear A
         LDA $49         ; Top BG1 row
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         AND #$FF        ; ...
         REP #$20        ; 16-bit A
         CLC             ; Prepare ADC
         ADC.L C35545,X  ; Add V-Data
         STA $7E9849,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0063      ; Past list?			=== SNES: #$005A (shorter table)
         BNE C35503      ; Loop if not
C35529:  LDA.L C35545,X  ; Bottom V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         CPX #$0067      ; End of table?		=== SNES: #$005E (shorter table)
         BNE C35529      ; Loop if not
         RTS

; BG1 H-Shift table for skill menus (merges tilemaps)
C35538:  db $27,$00,$01  ; Nothing
         db $3C,$00,$01  ; Member stats			=== SNES: Line counts differ (resized windows)
         db $6C,$00,$00  ; Spells, etc.
         db $1E,$00,$01  ; Nothing
         db $00          ; End

; BG1 V-Shift table for skill menus (condenses text)
C35545:  db $3F,$00,$00  ; LV
         db $0C,$04,$00  ; HP
         db $0C,$08,$00  ; MP
         db $0A,$0C,$00  ; Nothing
         db $01,$0C,$00  ; Nothing
         db $01,$0C,$00  ; Nothing			=== SNES: Line count differs
         db $04,$A0,$FF  ; Ability row A		=== SNES: Shift amounts below differ
         db $04,$A0,$FF  ; Ability row B
         db $04,$A0,$FF  ; Ability row C
         db $04,$A4,$FF  ; Ability row D
         db $04,$A4,$FF  ; Ability row E
         db $04,$A4,$FF  ; Ability row F
         db $04,$A8,$FF  ; Ability row G
         db $04,$A8,$FF  ; Ability row H
         db $04,$A8,$FF  ; Ability row I
         db $04,$AC,$FF  ; Ability row J
         db $04,$AC,$FF  ; Ability row K
         db $04,$AC,$FF  ; Ability row L
         db $04,$B0,$FF  ; Ability row M
         db $04,$B0,$FF  ; Ability row N
         db $04,$B0,$FF  ; Ability row O
         db $04,$B4,$FF  ; Ability row P
         db $04,$B4,$FF  ; Ability row Q
         db $04,$B4,$FF  ; Ability row R
         db $04,$B8,$FF  ; Ability row S
         db $04,$B8,$FF  ; Ability row T
         db $04,$B8,$FF  ; Ability row U
         db $04,$BC,$FF  ; Ability row V
         db $04,$BC,$FF  ; Ability row W
         db $04,$BC,$FF  ; Ability row X
         db $04,$C0,$FF  ; Ability row Y
         db $04,$C0,$FF  ; Ability row Z		%%%
         db $04,$C0,$FF  ; Ability row Þ		%%%
         db $1E,$20,$FF  ; Nothing?
         db $00          ; End

; Load member's SRAM block address for Skills menu
C355AC:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; SRAM address
         RTS

; Draw actor info in Skills menu
C355B4:  JSR C355AC      ; Actor's address
         STY $67         ; Memorize it
         JMP C355BC      ; ...
C355BC:  LDY #$42DB      ; Class/KO pos			=== SNES: Shifted rightward (resized windows)
         LDX #$4748      ; Icon position		=== SNES: Same as above
         JSR C334C2      ; Do class/status		=== SNES: No class
         LDY #C36333     ; Text pointer
         JSR C302F9      ; Draw HP's "/"
         LDY #C36337     ; Text pointer
         JSR C302F9      ; Draw MP's "/"
         LDX #C355E1     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
C355D7:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$41DB      ; Text position		=== SNES: +40h as no diacritics; shifted rightward as submenu list window is larger
         JMP C335AE      ; Draw held esper

; Tilemap pointers for stats in Skills menu
C355E1:  dw $4237        ; Level
         dw $42B3        ; HP
         dw $42BD        ; Max HP
         dw $4333        ; MP
         dw $433D        ; Max MP

; Build Magic list based on Mag.Order
C355EB:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDX #$003C      ; Slots: 60			=== SNES: 54 (no separators)
         LDA #$FF        ; Spell: None
C355F6:  STA $2180       ; Add to list
         DEX             ; One less spell
         BNE C355F6      ; Loop till last
         TDC             ; Clear A
         TAY             ; List slot: 1
         LDA $1D54       ; Game options
         AND #$07        ; Get Mag.Order
         ASL A           ; x2
         ASL A           ; x4
         TAX             ; Index it
C35606:  PHX             ; Save index
         LDA.L C35618,X  ; Starting spell
         CMP #$FF        ; At terminator?
         BEQ C35616      ; Exit if so
         JSR C35630      ; Populate list
         PLX             ; Type index
         INX             ; Index +1
         BRA C35606      ; Do next type
C35616:  PLX             ; Unstack index
         RTS

; Starting spell for each Magic type, sorted based on Mag.Order
C35618:  db $2D,$00,$18,$FF  ; 1: Cure, Fire, Scan
         db $2D,$18,$00,$FF  ; 2: Cure, Scan, Fire
         db $00,$18,$2D,$FF  ; 3: Fire, Scan, Cure
         db $00,$2D,$18,$FF  ; 4: Fire, Cure, Scan
         db $18,$2D,$00,$FF  ; 5: Scan, Cure, Fire
         db $18,$00,$2D,$FF  ; 6: Scan, Fire, Cure

; Add spells of given type to Magic list based on starting spell
C35630:  CMP #$00        ; Fire?
         BEQ C3563D      ; Branch if so
         CMP #$2D        ; Cure?
         BEQ C35642      ; Branch if so
         LDX #$0015      ; Spells: 21
         BRA C35647      ; Build list

; Fork: Black magic
C3563D:  LDX #$0018      ; Spells: 24
         BRA C35647      ; Build list

; Fork: White magic
C35642:  LDX #$0009      ; Spells: 9
         BRA C35647      ; ...

; Fork: Populate list
C35647:  STX $E0         ; Set spells left
         TAX             ; ...
C3564A:  TYX             ; List slot
         STA $7E9D89,X   ; Add spell there
         INC A           ; Spell number +1
         INY             ; List slot +1
         DEC $E0         ; One less spell
         BNE C3564A      ; Loop till last

; Fork: Skip a row to add a separator			%%%
C35655:  INY             ; List slot +1
         INY             ; List slot +1
         INY             ; List slot +1
         RTS

; Draw Magic list
C35659:  JSR C38B78      ; Define $E5, $E6
         LDY #$0009      ; Rows left: 9			=== SNES: 8
C3565F:  PHY             ; Save counter
         JSR C35670      ; Draw 3 spells		=== SNES: 2
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C3565F      ; Loop till last
         RTS

; Draw a row of three spells in Magic menu		=== SNES: 2
C35670:  JSR C35692      ; Define source
         LDX #$0003      ; X: 3
         JSR C356A1      ; Draw spell A
         INC $E5         ; Menu slot +1
         JSR C35692      ; Define source
         LDX #$000C      ; X: 12			=== SNES: 16
         JSR C356A1      ; Draw spell B
         INC $E5         ; Menu slot +1
         JSR C35692      ; Define source		%%%
         LDX #$0015      ; X: 21
         JSR C356A1      ; Draw spell C
         INC $E5         ; Menu slot +1
         RTS

; Set source for loading Magic name
C35692:  LDY #$0005      ; Letters: 5			=== SNES: 7
         STY $EB         ; Set src size
         LDY #$7400      ; ED/7400			=== SNES: E6/F567
         STY $EF         ; Set src LBs
         LDA #$ED        ; Bank: ED			=== SNES: E6
         STA $F1         ; Set src HB
         RTS

; Draw text in spell slot of Magic menu
C356A1:  LDA $E6         ; BG1 write row

         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDA $9E         ; Show MP in list?
         BEQ C35715      ; Branch if not
         JSR C357BB      ; Spell
         JSR C3581C      ; Handle graying
         JSR C357BB      ; Spell
         CMP #$FF        ; None?
         BEQ C356F1      ; Blank if so
         JSR C35771      ; Spell mastery
         CMP #$FF        ; Fully learned?
         BNE C356F1      ; Blank if not

; Fork: Draw spell plus MP cost
C356C7:  JSR C357BB      ; Spell
         JSR C38BF2      ; Load name
         LDX #$9E90      ; 7E/9E90			=== SNES: 7E/9E92 (longer string)
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
         STA $2180       ; Add to string
         JSR C357BB      ; Spell
         JSR C357DC      ; Define MP cost
         JSR C30563      ; Turn into text
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string


         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Blank spell slot
C356F1:  TDC             ; Clear A
         LDA $E5         ; Spell slot
         TAX             ; Index it
         LDA #$FF        ; Spell: None
         STA $7E9D89,X   ; Assign to slot
         JSR C35888      ; Disable spell
         LDY #$0008      ; Letters: 8			=== SNES: 11
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C35709:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C35709      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 8 spaces		=== SNES: 11

; Fork: Draw spell plus percentage
C35715:  JSR C357BB      ; Spell
         CMP #$FF        ; None?
         BEQ C356F1      ; Blank if so
         JSR C35771      ; Spell mastery
         CMP #$00        ; Zero?
         BEQ C356F1      ; Blank if so
         JSR C357BB      ; Spell
         JSR C38BF2      ; Load name
         LDX #$9E90      ; 7E/9E90			=== SNES: 7E/9E92 (longer string)
         STX $2181       ; Set WRAM LBs
         JSR C357BB      ; Spell
         JSR C35771      ; Spell mastery
         CMP #$FF        ; Fully learned?
         BEQ C3575A      ; Branch if so
         PHA             ; Save mastery
         JSR C35888      ; Disable spell
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Bluish


         PLA             ; Spell mastery
         JSR C30563      ; Turn into text
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string
         LDA #$CD        ; Char: "%"
         STA $2180       ; Add to string
C35754:  STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Draw spell name only
C3575A:  LDA #$24        ; Palette 1
         STA $29         ; Color: Blue...
         JSR C357BB      ; Spell
         JSR C3581C      ; Handle graying
         LDA #$FF        ; Space char
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string

         BRA C35754      ; Draw string

; Get spell's mastery percentage
C35771:  STA $E0         ; Save spell
         JSR C355AC      ; Define Y
         LDA $0000,Y     ; Actor
         CMP #$0C        ; Gogo?
         BEQ C35794      ; Branch if so
C3577D:  STA $4202       ; Set multiplicand
         LDA #$36        ; Spell list size
         STA $4203       ; Set multiplier
         TDC             ; Clear A
         LDA $E0         ; Spell
         REP #$20        ; 16-bit A
         ADC $4216       ; Add product
         TAX             ; Index sum
         SEP #$20        ; 8-bit A
         LDA $1A6E,X     ; Spell mastery
         RTS

; Fork: Test all members for Gogo
C35794:  STZ $E1         ; Member slot: 1
C35796:  TDC             ; ...
         LDA $E1         ; Tested member
         CMP $28         ; Gogo?
         BEQ C357B1      ; Skip if so
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         BEQ C357B1      ; Skip if nobody
         LDA $0000,Y     ; Actor in slot
         CMP #$0C        ; Gogo or higher?
         BCS C357B1      ; Skip if so
         JSR C3577D      ; Actor's mastery
         CMP #$FF        ; Fully learned?
         BEQ C357BA      ; Exit if so
C357B1:  INC $E1         ; Member slot +1
         LDA $E1         ; Members done
         CMP #$04        ; Done all 4?
         BNE C35796      ; Loop if not
         TDC             ; Mastery: 0
C357BA:  RTS

; Get processed spell
C357BB:  TDC             ; Clear A
         LDA $E5         ; Spell slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Spell in slot
         RTS

; Compute spell data index
C357C4:  PHA             ; Save spell
C357C5:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C357C5      ; Loop if not
         PLA             ; Spell
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$0E        ; Data size
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         RTS

; Define spell's MP cost
C357DC:  PHA             ; Save spell
         JSR C357C4      ; Compute index
         LDX $2134       ; Load it
         LDA $C46AC5,X   ; Base MP cost
         STA $E0         ; Memorize it

; Fork: Step Mine
C357E9:  PLA             ; Spell
         CMP #$99        ; Step Mine?
         BNE C357FD      ; Branch if not
         LDA $021B       ; Hours played
         ASL A           ; Double them
         STA $E0         ; Set MP cost
         LDA $021C       ; Minutes played
         CMP #$1E        ; Under 30?
         BCC C357FD      ; Branch if so
         INC $E0         ; MP cost +1

; Fork: Economizer
C357FD:  LDA $11D7       ; Gear effects
         BIT #$40        ; Economizer's?
         BEQ C35809      ; Branch if not
         TDC             ; Clear A
         LDA #$01        ; MP cost: 1
         BRA C3581A      ; Put it in X

; Fork: Gold Hairpin
C35809:  LDA $11D7       ; Gear effects
         BIT #$20        ; Gold Hairpin?
         BEQ C35817      ; Branch if not
         TDC             ; Clear A
         LDA $E0         ; MP cost
         INC A           ; Add one
         LSR A           ; Halve it
         BRA C3581A      ; Put it in X

; Fork: Normal MP cost
C35817:  TDC             ; Clear A
         LDA $E0         ; Base MP cost
C3581A:  TAX             ; Put it in X
         RTS

; Enable or disable spell in Magic menu
C3581C:  CMP #$2A        ; Warp?
         BEQ C3584A      ; Branch if so
         CMP #$12        ; X-Zone?
         BEQ C3583D      ; Branch if so
C35824:  JSR C357C4      ; Compute index
         LDX $2134       ; Load it
         LDA $C46AC3,X   ; Spell properties
         AND #$01        ; Usable in field?
         BEQ C3583B      ; Disable if not
         JSR C357BB      ; Spell
         JSR C357DC      ; Define MP cost
         JMP C35857      ; Test MP and Imp

; Fork: Disable spell
C3583B:  BRA C35888      ; Go directly...

; Fork: X-Zone (unused feature)
C3583D:  STA $E3         ; Memorize spell
         LDA $0201       ; Area permissions
         BIT #$01        ; Forbid X-Zone?
         BEQ C3583B      ; Disable if so
         LDA $E3         ; Spell number
         BRA C35824      ; Do basic checks

; Fork: Warp
C3584A:  STA $E3         ; Memorize spell
         LDA $0201       ; Area permissions
         BIT #$02        ; Can warp here?
         BEQ C3583B      ; Disable if not
         LDA $E3         ; Spell number
         BRA C35824      ; Do basic checks

; Fork: Test Imp
C35857:  STX $E2         ; Save MP cost
         JSR C355AC      ; Define Y
         LDA $0014,Y     ; Actor's status
         AND #$20        ; Imp?
         BEQ C3586A      ; Branch if not
         JSR C357BB      ; Spell
         CMP #$23        ; Imp?
         BNE C35888      ; Disable if not

; Fork: Test MP
C3586A:  REP #$20        ; 16-bit A
         LDA $000D,Y     ; Actor's MP
         STA $E0         ; Memorize it
         SEP #$20        ; 8-bit A
         LDX $E2         ; MP cost
         CPX $E0         ; Equals user MP?
         BEQ C3587B      ; Enable if so
         BCS C35888      ; Block if above

; Fork: Enable spell
C3587B:  TDC             ; Clear A
         LDA $E5         ; Spell slot
         TAX             ; Index it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         STA $7E9E09,X   ; Enable spell
         RTS

; Fork: Disable spell
C35888:  TDC             ; Clear A
         LDA $E5         ; Spell slot
         TAX             ; Index it
         LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         STA $7E9E09,X   ; Disable spell
         RTS

; Draw MP cost in corner of Magic menu
C35895:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         REP #$20        ; 16-bit A
         LDA #$80D3      ; Tilemap ptr			=== SNES: Opposite corner
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         LDA $4B         ; List slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Spell in slot
         JSR C357DC      ; Define MP cost
         JSR C30563      ; Turn into text
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string
         STZ $2180       ; End string
         JMP C387B9      ; Draw MP cost

; Draw Lore list and menu title, create portrait
C358C8:  JSR C371A9      ; Clear BG1 map A
         JSR C3590B      ; Draw Lore list
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C362EE     ; Text pointer
         JSR C30326      ; Draw "Lore"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload

; Build Lore list
C358DE:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Index: 0
         STZ $E0         ; 1st: Condemned
C358E8:  LDY #$0008      ; Lores left: 8
         LDA $1D29,X     ; 8 known lores
C358EE:  ROR A           ; Got current?
         PHA             ; Save 8 lores
         BCC C358F9      ; Blank if not
         LDA $E0         ; Lore number
         STA $2180       ; Add to list
         BRA C358FE      ; Skip 2 lines
C358F9:  LDA #$FF        ; Esper: None
         STA $2180       ; Add to list
C358FE:  INC $E0         ; Lore number +1
         PLA             ; 8 known lores
         DEY             ; Lores left -1
         BNE C358EE      ; Loop till last
         INX             ; Point to next 8
         CPX #$0003      ; Done 24 lores?
         BNE C358E8      ; Loop if not
         RTS

; Build and draw Lore list
C3590B:  JSR C358DE      ; Build Lore list
         JSR C38B78      ; Define $E5, $E6
         LDY #$0009      ; Lores left: 9		=== SNES: 8
C35914:  PHY             ; Save counter
         JSR C35925      ; Draw Lore row		=== SNES: One Lore per row
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Lores left
         DEY             ; One less left
         BNE C35914      ; Loop till last
         RTS

; Draw a row of two Lore names, includng MP cost	=== SNES: One Lore per row
C35925:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C35940      ; Define source
         LDX #$0003      ; X: 3
         JSR C3594F      ; Draw Lore A
         INC $E5         ; Lore slot +1
         JSR C35940      ; Define source		%%%
         LDX #$0011      ; X: 17
         JSR C3594F      ; Draw Lore B
         INC $E5         ; Lore slot +1
         RTS

; Set source for loading Lore name
C35940:  LDY #$0008      ; Letters: 8			=== SNES: 8
         STY $EB         ; Set src size
         LDY #$77B6      ; ED/77B6			=== SNES: E6/F9FD
         STY $EF         ; Set src LBs
         LDA #$ED        ; Bank: ED			=== SNES: E6
         STA $F1         ; Set src HB
         RTS

; Draw Lore's name and MP cost
C3594F:  LDA $E6         ; BG1 write row

         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Lore slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Lore in slot
         CMP #$FF        ; None?
         BEQ C35999      ; Blank if so
         LDA $E5         ; Lore slot
         JSR C38BF2      ; Load name
         LDX #$9E93      ; 7E/9E93			=== SNES: 7E/9E95 (longer name)
         STX $2181       ; Set WRAM LBs
         LDA #$C7        ; Char: ".."			=== SNES: "…"
         STA $2180       ; Add to string
         LDA $E5         ; Lore slot
         CLC             ; Prepare ADC
         ADC #$8B        ; Get attack ID
         JSR C357DC      ; Define MP cost
         JSR C30563      ; Turn into text
         LDA $F7         ; Hundreds digit
         STA $2180       ; Add to string
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Blank Lore slot
C35999:  LDY #$000C      ; Letters: 12			=== SNES: 14
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C359A4:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C359A4      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 12 spaces		=== SNES: 14

; Draw SwdTech list and menu title, create portrait
C359B0:  JSR C371A9      ; Clear BG1 map A
         JSR C359C9      ; Build tech list


         JSR C3AE09      ; And its tilemap		=== SFC uses 2x2 kanji
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C3631B     ; Text pointer
         JSR C30326      ; Draw "SwdTech"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload



































































; Build SwdTech list
C359C9:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDY #$0008      ; Techs left: 8
         STZ $E0         ; 1st: Dispatch
         TDC             ; ...
         LDA $1CF7       ; 8 known techs
C359D8:  ROR A           ; Got current?
         PHA             ; Save 8 techs
         BCC C359E0      ; Blank if not
         LDA $E0         ; SwdTech number
         BRA C359E2      ; Skip a line
C359E0:  LDA #$FF        ; SwdTech: None
C359E2:  STA $2180       ; Add to list
         INC $E0         ; Tech number +1
         PLA             ; 8 known techs
         DEY             ; Techs left -1
         BNE C359D8      ; Loop till last
         RTS

; Draw Rage list and menu title, create portrait
C359EC:  JSR C371A9      ; Clear BG1 map A
         JSR C35A02      ; Draw Rage list
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C362F7     ; Text pointer
         JSR C30326      ; Draw "Rage"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload

; Build and draw Rage list
C35A02:  JSR C35A1C      ; Build Rage list
         JSR C38B78      ; Define $E5, $E6
         LDY #$0009      ; Rows left: 9			=== SNES: 9 too but should be 8
C35A0B:  PHY             ; Save counter
         JSR C35A49      ; Draw 2 Rages
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C35A0B      ; Loop till last
         RTS

; Build Rage list
C35A1C:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Pack index: 0
         STZ $E0         ; Current: Guard
C35A26:  LDY #$0008      ; Rages left: 8
         LDA $1D2C,X     ; 8 known Rages
C35A2C:  ROR A           ; Got current?
         PHA             ; Save 8 Rages
         BCC C35A37      ; Blank if not
         LDA $E0         ; Rage number
         STA $2180       ; Add to list
         BRA C35A3C      ; Skip 2 lines
C35A37:  LDA #$FF        ; Rage: None
         STA $2180       ; Add to list
C35A3C:  INC $E0         ; Rage number +1
         PLA             ; 8 known Rages
         DEY             ; Rages left -1
         BNE C35A2C      ; Loop till last
         INX             ; Point to next 8
         CPX #$0020      ; Done 256 Rages?
         BNE C35A26      ; Loop if not
         RTS

; Draw a row of two Rages
C35A49:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C35A64      ; Define source
         LDX #$0005      ; X: 5
         JSR C35A73      ; Draw Rage A
         INC $E5         ; Rage slot +1
         JSR C35A64      ; Define source
         LDX #$0013      ; X: 19
         JSR C35A73      ; Draw Rage B
         INC $E5         ; Rage slot +1
         RTS

; Set source for loading enemy name
C35A64:  LDY #$0008      ; Letters: 8			=== SNES: 10
         STY $EB         ; Set src size
         LDY #$C800      ; CF/C800			=== SNES: CF/C050
         STY $EF         ; Set src LBs
         LDA #$CF        ; Bank: CF
         STA $F1         ; Set src HB
         RTS

; Draw Rage name
C35A73:  LDA $E6         ; BG1 write row

         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Rage slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Rage in slot
         CMP #$FF        ; None or Pugs?
         BEQ C35A95      ; Blank if so
         LDA $E5         ; Rage slot
         JSR C38BF2      ; Load name
         JMP C387B9      ; Draw name

; Fork: Blank Rage slot
C35A95:  LDY #$0008      ; Spaces: 8			=== SNES: 10
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C35AA0:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C35AA0      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 8 spaces		=== SNES: 10

; Draw esper list and menu title, create portrait
C35AAC:  JSR C371A9      ; Clear BG1 map A
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C35AC6      ; Draw esper list
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C36309     ; Text pointer
         JSR C30326      ; Draw "Espers"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload

; Build and draw esper list
C35AC6:  JSR C35AE0      ; Build esper list
         JSR C38B78      ; Define $E5, $E6
         LDY #$0009      ; Rows left: 9			=== SNES: 8
C35ACF:  PHY             ; Save counter
         JSR C35B3D      ; Draw 2 espers
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C35ACF      ; Loop till last
         RTS

; Build sorted esper list
C35AE0:  LDX #$9DED      ; 7E/9DED
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Pack index: 0
         STZ $E0         ; Current: Ramuh
C35AEA:  LDY #$0008      ; Espers left: 8
         LDA $1A69,X     ; 8 owned espers
C35AF0:  ROR A           ; Got current?
         PHA             ; Save 8 espers
         BCC C35AFB      ; Blank if not
         LDA $E0         ; Esper number
         STA $2180       ; Add to list
         BRA C35B00      ; Skip 2 lines
C35AFB:  LDA #$FF        ; Esper: None
         STA $2180       ; Add to list
C35B00:  INC $E0         ; Esper number +1
         PLA             ; 8 owned espers
         DEY             ; Espers left -1
         BNE C35AF0      ; Loop till last
         INX             ; Point to next 8
         CPX #$0004      ; Done 32 espers?
         BNE C35AEA      ; Loop if not

; Fork: Clear sorted list
C35B0C:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Esper: None
         LDX #$001D      ; Slots left: 29
C35B17:  STA $2180       ; Clear list slot
         DEX             ; One less left
         BNE C35B17      ; Loop till last

; Fork: Build sorted list
C35B1D:  LDX #$9DED      ; 7E/9DED
         STX $2181       ; Set WRAM LBs
         LDY #$001B      ; Slots left: 27
         TDC             ; Clear A
C35B27:  LDA $2180       ; Esper in slot
         BMI C35B39      ; Skip if none
         PHA             ; Memorize it
         TAX             ; Index it
         LDA $D1F9B5,X   ; Intended slot
         DEC A           ; Subtract 1
         TAX             ; Index it
         PLA             ; Esper number
         STA $7E9D89,X   ; Add to new list
C35B39:  DEY             ; One less esper
         BNE C35B27      ; Loop till last
         RTS

; Draw a row of two esper names with MP cost
C35B3D:  JSR C35B54      ; Define source
         LDX #$0003      ; X: 3
         JSR C35B63      ; Draw esper A
         INC $E5         ; Esper slot +1
         JSR C35B54      ; Define source
         LDX #$0011      ; X: 17
         JSR C35B63      ; Draw esper B
         INC $E5         ; Esper slot +1
         RTS

; Set source for loading esper name
C35B54:  LDY #$0008      ; Letters: 8
         STY $EB         ; Set src size
         LDY #$750E      ; ED/750E			=== SNES: E6/F6E1
         STY $EF         ; Set src LBs
         LDA #$ED        ; Bank: ED			=== SNES: E6
         STA $F1         ; Set src HB
         RTS

; Draw esper's name and MP cost
C35B63:  LDA $E6         ; BG1 write row

         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Esper slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Esper in slot
         CMP #$FF        ; None?
         BEQ C35BB6      ; Blank if so
         JSR C35BCD      ; Choose palette
         JSR C38BF2      ; Load name
         TDC             ; ...
         LDA $E5         ; Esper slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Esper in slot
         CLC             ; Prepare ADC
         ADC #$36        ; Get attack ID
         JSR C357DC      ; Define MP cost
         PHA             ; Memorize it
         LDX #$9E93      ; 7E/9E93			=== SNES: 7E/9E95 (longer name)
         STX $2181       ; Set WRAM LBs
         LDA #$C7        ; Char: ".."			=== SNES: "…"
         STA $2180       ; Add to string
         PLA             ; MP cost
         JSR C30563      ; Turn into text
         LDA $F7         ; Hundreds digit
         STA $2180       ; Add to string
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Blank esper slot
C35BB6:  LDY #$000C      ; Spaces: 12
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C35BC1:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C35BC1      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 12 spaces

; Define esper name color
C35BCD:  STA $E0         ; Save esper
         LDX $00         ; 1st: Terra
         LDY #$0010      ; Actors: 16
C35BD4:  LDA $161E,X     ; Actor's esper
         CMP $E0         ; Matches ours?
         BEQ C35BEC      ; Gray out if so
         REP #$20        ; 16-bit A
         TXA             ; Actor address
         CLC             ; Prepare ADC
         ADC #$0025      ; Actor slot +1
         TAX             ; Reindex it
         SEP #$20        ; 8-bit A
         DEY             ; One less actor
         BNE C35BD4      ; Loop till last
         LDA #$20        ; Color: User's
         BRA C35BEE      ; Skip a line
C35BEC:  LDA #$28        ; Color: Gray
C35BEE:  STA $29         ; Set palette
         LDA $E0         ; Esper to draw
         RTS

; Draw "<actor> has it!" in esper data menu
C35BF3:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         REP #$20        ; 16-bit A
         LDA #$40DD      ; Tilemap ptr			=== SNES: Shifted leftward but fails to add 40h (no diacritics)
         STA $7E9E89     ; Set position
         LDA #$9E8B      ; 7E/9E8B
         STA $2181       ; Set WRAM LBs
         SEP #$20        ; 8-bit A
         LDY #$0006      ; Letters: 6
C35C0B:  LDA $1602,X     ; Name letter
         CMP #$FF        ; Terminator?
         BEQ C35C19      ; Done if so
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C35C0B      ; Loop till last
C35C19:  LDX $00         ; Letter: 1st
C35C1B:  LDA.L C3633B,X  ; Message letter
         BEQ C35C27      ; Done if end
         STA $2180       ; Add to string
         INX             ; Point to next
         BRA C35C1B      ; Do next letter
C35C27:  STZ $2180       ; End string
         JMP C387B9      ; Draw message

; Draw Blitz inputs and menu title, create portrait
C35C2D:  JSR C371A9      ; Clear BG1 map A
         JSR C35C43      ; Draw inputs
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C36312     ; Text pointer
         JSR C30326      ; Draw "Blitz"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload

; Build Blitz list and draw Blitz inputs
C35C43:  JSR C35C78      ; Build Blitz list
         JSR C38B78      ; Define $E5, $E6
         STZ $E5         ; Blitz slot: 1
         INC $E6         ; BG1 write row +1
         INC $E6         ; BG1 write row +1		%%%
         INC $E6         ; BG1 write row +1		%%%
         LDY #$0004      ; Rows left: 4
C35C54:  PHY             ; Save counter
         JSR C35C67      ; Draw inputs x2
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C35C54      ; Loop till last
         RTS

; Draw a row of two sets of Blitz inputs
C35C67:  LDX #$0005      ; X: 5				=== SNES: 4
         JSR C35CA0      ; Draw inputs A
         INC $E5         ; Blitz slot +1
         LDX #$0013      ; X: 19			=== SNES: 18
         JSR C35CA0      ; Draw inputs B
         INC $E5         ; Blitz slot +1
         RTS

; Build Blitz list
C35C78:  LDA $1D28       ; Known Blitzes
         BRA C35C80      ; Run Dance code

; Build Dance list
C35C7D:  LDA $1D4C       ; Known Dances
C35C80:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDX $00         ; 1st: Wind Song
         LDY #$0008      ; Dances left: 8
C35C8B:  ROR A           ; Know current?
         PHA             ; Save 8 Dances
         BCC C35C95      ; Blank if not
         TXA             ; Dance number
         STA $2180       ; Add to list
         BRA C35C9A      ; Skip 2 lines
C35C95:  LDA #$FF        ; Dance: None
         STA $2180       ; Add to list
C35C9A:  INX             ; Dance number +1
         PLA             ; Known Dances
         DEY             ; One less Dance
         BNE C35C8B      ; Loop till last
         RTS

; Draw Blitz's inputs
C35CA0:  LDA $E6         ; BG1 write row
         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Blitz slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Blitz in slot
         CMP #$FF        ; None?
         BEQ C35CC9      ; Blank if so
         JSR C35CE0      ; Build tilemap
         LDY #$9E89      ; 7E/9E89
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JMP C35D19      ; Move tilemap

; Fork: Blank Blitz slot
C35CC9:  LDY #$0008      ; Spaces: 8
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C35CD4:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C35CD4      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 8 spaces

; Build tilemap for Blitz's inputs
C35CE0:  PHA             ; Save Blitz
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         STA $E0         ; Memorize it
         PLA             ; Blitz
         ASL A           ; x2
         ASL A           ; x4
         CLC             ; ...
         ADC $E0         ; x12
         TAX             ; Index it
         LDY #$9E8B      ; 7E/9E8B
         STY $2181       ; Set WRAM LBs
         LDY #$000A      ; Inputs: 10
C35CF6:  PHX             ; Save index
         LDA $C47A40,X   ; Blitz input
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C36274,X  ; Tile number
         STA $2180       ; Save in WRAM
         INX             ; Index +1
         LDA.L C36274,X  ; Attributes
         STA $2180       ; Save in WRAM
         INX             ; ...
         PLX             ; Input index
         INX             ; Input index +1
         DEY             ; One less input
         BNE C35CF6      ; Loop till last
         STZ $2180       ; End string LB
         STZ $2180       ; End string HB
         RTS

; Apply tilemap for Blitz's inputs
C35D19:  LDY $00         ; Index: 0
         REP #$20        ; 16-bit A
         LDA [$E7]       ; Tilemap ptr
         STA $EB         ; Set dest LBs
         INC $E7         ; Source +1
         INC $E7         ; Source +1
         SEP #$20        ; 8-bit A
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dest HB
C35D2B:  REP #$20        ; 16-bit A
         LDA [$E7],Y     ; Tile data
         BEQ C35D39      ; Exit if end
         STA [$EB],Y     ; Add to map
         SEP #$20        ; 8-bit A
         INY             ; Index +1
         INY             ; Index +1
         BRA C35D2B      ; Do next tile
C35D39:  SEP #$20        ; 8-bit A
         RTS

; Load esper description
C35D3C:  JSR C36261      ; Load pointers
         JMP C35D87      ; Load description

; Load Magic description
C35D42:  JSR C3623B      ; Load pointers
         JMP C35D87      ; Load description

; Load Lore description
C35D48:  LDX #$FF3E      ; CF/FF3E			=== SNES: ED/7A70
         STX $E7         ; Set ptr loc LBs
         LDX #$FE00      ; ED/FE00			=== SNES: ED/77A0
         STX $EB         ; Set text loc LBs
         LDA #$CF        ; Bank: CF			=== SNES: ED
         STA $E9         ; Set ptr loc HB
         LDA #$ED        ; Bank: ED
         STA $ED         ; Set text loc HB
         JMP C35D87      ; Load description

; Load SwdTech description
C35D5D:  LDX #$FFAE      ; CF/FFAE
         STX $E7         ; Set ptr loc LBs
         LDX #$FD00      ; CF/FD00
         STX $EB         ; Set text loc LBs
         LDA #$CF        ; Bank: CF
         STA $E9         ; Set ptr loc HB
         LDA #$CF        ; ...
         STA $ED         ; Set text loc HB
         JMP C35D87      ; Load description

; Load Blitz description
C35D72:  LDX #$FF9E      ; CF/FF9E
         STX $E7         ; Set ptr loc LBs
         LDX #$FC00      ; CF/FC00
         STX $EB         ; Set text loc LBs
         LDA #$CF        ; Bank: CF
         STA $E9         ; Set ptr loc HB
         LDA #$CF        ; ...
         STA $ED         ; Set text loc HB
         JMP C35D87      ; ...

; Load skill or item description
C35D87:  LDX #$9EC9      ; 7E/9EC9
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         LDA $4B         ; List slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Skill or item
C35D95:  CMP #$FF        ; Empty slot?
         BEQ C35DCA      ; Blank if so
C35D99:  REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAY             ; Index it
         LDA [$E7],Y     ; Relative ptr
         TAY             ; Index it
         SEP #$20        ; 8-bit A
C35DA2:  LDA [$EB],Y     ; Text character
         BEQ C35DAC      ; Branch if 00h
         STA $2180       ; Add to string
         INY             ; Index +1
         BRA C35DA2      ; Do next char

; Fork: Check if terminator
C35DAC:  DEY             ; Index -1
         LDA [$EB],Y     ; Previous char
         INY             ; Index +1
         CMP #$1C        ; Command 1C?
         BEQ C35DC4      ; Branch if so
         CMP #$1D        ; Command 1D?
         BEQ C35DC4      ; Branch if so
         CMP #$1E        ; Command 1E?
         BEQ C35DC4      ; Branch if so
         CMP #$1F        ; Command 1F?
         BEQ C35DC4      ; Branch if so
C35DC0:  STZ $2180       ; End string
         RTS

; Fork: Resume past control code
C35DC4:  STZ $2180       ; Add 00h to msg
         INY             ; Index +1
         BRA C35DA2      ; Do next char

; Fork: Empty slot (space is for item usage menu)
C35DCA:  LDA #$FF        ; Space char
         STA $2180       ; Add to string
         BRA C35DC0      ; End string

; Draw Dance list and menu title, create portrait
C35DD1:  JSR C371A9      ; Clear BG1 map A
         JSR C35DE7      ; Draw Dance list
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C36300     ; Text pointer
         JSR C30326      ; Draw "Dance"
         JSR C36802      ; Create portrait
         JMP C30FB8      ; Queue BG3 upload

; Build and draw Dance list
C35DE7:  JSR C35C7D      ; Build Dance list
         JSR C38B78      ; Define $E5, $E6
         INC $E6         ; BG1 write row +1
         INC $E6         ; BG1 write row +1		%%%
         STZ $E5         ; Dance slot: 1
         LDY #$0004      ; Rows left: 4
C35DF6:  PHY             ; Save counter
         JSR C35E09      ; Draw 2 dances
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C35DF6      ; Loop till last
         RTS

; Draw a row of two Dance names
C35E09:  JSR C35E20      ; Define source
         LDX #$0005      ; X: 5				=== SNES: 3
         JSR C35E2F      ; Draw Dance A
         INC $E5         ; Dance slot +1
         JSR C35E20      ; Define source
         LDX #$0013      ; X: 19			=== SNES: 17
         JSR C35E2F      ; Draw Dance B
         INC $E5         ; Dance slot +1
         RTS

; Set source for loading Dance name
C35E20:  LDY #$0008      ; Letters: 8			=== SNES: 12
         STY $EB         ; Set src size
         LDY #$7C51      ; ED/7C51			=== SNES: E6/FF9D
         STY $EF         ; Set src LBs
         LDA #$ED        ; Bank: ED			=== SNES: E6
         STA $F1         ; Set src HB
         RTS

; Draw Dance name
C35E2F:  LDA $E6         ; BG1 write row
         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Dance slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Dance in slot
         CMP #$FF        ; Empty slot?
         BEQ C35E4F      ; Blank if so
         JSR C38BF2      ; Load name
         JMP C387B9      ; Draw name

; Fork: Blank Dance slot
C35E4F:  LDY #$0008      ; Spaces: 8			=== SNES: 12
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C35E5A:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C35E5A      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 8 spaces		=== SNES: 12

; Set to delete portrait in Skills menu
C35E66:  TDC             ; Clear A
         LDA $60         ; Queue index
         TAX             ; Index it
         LDA #$FF        ; Null value
         STA $7E35C9,X   ; Portrait: Off
         RTS

; Draw and upload spell usage menu
C35E71:  JSR C371BC      ; Clear BG2 map A
         LDY #C35E9E     ; C3/5E9E
         JSR C303C4      ; Draw party box
         LDY #C35EA2     ; C3/5EA2
         JSR C303C4      ; Draw spell box
         LDY #C35EA6     ; C3/5EA6
         JSR C303C4      ; Draw cost box
         JSR C30EBD      ; Upload windows
         JSR C371AD      ; Clear BG1 map B
         LDY #$FFC0      ; X: -64 = 448
         STY $35         ; Set BG1 X-Pos
         LDA #$02        ; Portrait row bit
         TSB $45         ; Ignore back row
         JSR C33225      ; Draw party info
         JSR C35EAA      ; Draw spell, cost
         JMP C3323A      ; Upload text maps

; Window layout for spell usage menu
C35E9E:  dw $589D,$1813  ; 21x26 at $589D (Party)
C35EA2:  dw $588B,$0207  ; 09x04 at $588B (Spell)
C35EA6:  dw $598B,$0307  ; 09x05 at $598B (MP cost)

; Draw spell name and cost message for spell usage menu
C35EAA:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C35EE2     ; Text pointer
         JSR C30326      ; Draw "MP Needed"


         TDC             ; ...
         LDA $4B         ; Cursor slot
         STA $E5         ; Set spell slot
         JSR C35692      ; Define source
         REP #$20        ; 16-bit A
         LDA #$78CF      ; Tilemap ptr			=== SNES: +40h as no diacritics; shifted leftward as longer spell names
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         JSR C357BB      ; Spell
         JSR C38BF2      ; Load spell name
         JSR C387B9      ; Draw spell name
         JSR C357BB      ; Spell
         JSR C357DC      ; Define MP cost
         JSR C30563      ; Turn into text
         LDX #$7A53      ; Text position		=== SNES: Cost on first line instead of second
         JSR C30539      ; Draw 2 digits
         JMP C387B9      ; Redraw name...

; Positioned text, "MP Needed"
C35EE2:  dw $79CD : db |しょうひ MP[end]|			=== SNES position differs


; Initialize esper data menu
C35EEC:  LDY $4F         ; Cursor position
         STY $8E         ; Set return loc
         LDA $4A         ; Scroll position
         STA $90         ; Set return loc
         JSR C361AC      ; Load esper info
         JSR C35FF4      ; Draw esper info
         JSR C30F7C      ; Queue its upload
         JSR C313D3      ; Upload it now
         JSR C30F68      ; Requeue esper list
         REP #$20        ; 16-bit A
         LDA #$0100      ; BG1 H-Shift: 256
         STA $7E9A10     ; Hide esper list
         SEP #$20        ; 8-bit A
         LDA $49         ; Top BG1 write row
         STA $5F         ; Save for return
         LDA #$07        ; BG1 VRAM row: 7
         STA $49         ; Save for V-Shift
         JSR C354F3      ; Load V-shift data
         LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         JSR C35FD2      ; Load navig data
         JMP C35FDB      ; Relocate cursor

; 4D: Sustain esper data menu
C35F23:  JSR C35FD8      ; Handle D-Pad
         JSR C361EB      ; Load description
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C35F5F      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; On esper name?
         BNE C35F5F      ; Branch if not
         LDA $99         ; Viewed esper
         JSR C35BCD      ; Choose palette
         STA $E0         ; Memorize esper
         LDA $29         ; Esper palette
         CMP #$28        ; Grayed out?
         BNE C35F57      ; Equip if not
         JSR C30F2B      ; Play buzzer
         LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         JSR C35BF3      ; Draw who has it
         LDY #$0020      ; Frames: 32
         STY $20         ; Set exit delay
         LDA #$34        ; C3/29AD
         STA $26         ; Next: Late exit
         JMP C30F7C      ; Queue text upload

; Fork: Equip esper
C35F57:  JSR C30F1D      ; Sound: Click
         JSR C3299C      ; Equip/draw esper
         BRA C35F68      ; Exit submenu

; Fork: Handle B
C35F5F:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C35FD1      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C35F68:  LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         LDA $5F         ; Top BG1 write row
         STA $49         ; Restore it
         JSR C35AC6      ; Draw esper list
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$1333      ; V-Speed: 19.2 px		=== SNES: 16
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0060      ; Y: 96
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         JSR C352CD      ; Load navig data
         LDA $8E         ; Old cursor column
         STA $4D         ; Set onscreen col
         LDY $8E         ; Old cursor loc
         STY $4F         ; Set as current
         LDA $90         ; Old scroll pos
         STA $4A         ; Set as current
         LDA $4A         ; Scroll position
         STA $E0         ; Memorize it
         LDA $50         ; List row
         SEC             ; Prepare SBC
         SBC $E0         ; Deduct scroll pos
         STA $4E         ; Set cursor row
         JSR C352D6      ; Relocate cursor
         LDA #$05        ; Top row: Carb.'s		=== SNES: 6
         STA $5C         ; Set scroll limit
         LDA #$09        ; Onscreen rows: 9		=== SNES: 8
         STA $5A         ; Set rows per page
         LDA #$02        ; Onscreen cols: 2
         STA $5B         ; Set cols per page
         JSR C30F68      ; Queue list upload
         JSR C313D3      ; Refresh esper list
         REP #$20        ; 16-bit A
         TDC             ; BG1 H-Shift: 0
         STA $7E9A10     ; Unhide esper list
         SEP #$20        ; 8-bit A
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         STY $3D         ; Set BG3 X-Pos
         JSR C354F3      ; Load V-shift data
         JSR C30F7C      ; Queue stats upload
         LDA #$1E        ; C3/2946
         STA $26         ; Next: Esper choice
C35FD1:  RTS

; Load navigation data for esper data menu
C35FD2:  LDY #C35FE1     ; C3/5FE1
         JMP C30681      ; Load navig data

; Handle D-Pad for esper data menu
C35FD8:  JSR C307B0      ; Handle D-Pad
C35FDB:  LDY #C35FE6     ; C3/5FE6
         JMP C306C3      ; Relocate cursor

; Navigation data for esper data menu
C35FE1:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $07          ; 7 rows

; Cursor positions for esper data menu
C35FE6:  dw $7010        ; Esper
         dw $7C18        ; Spell A
         dw $8818        ; Spell B
         dw $9418        ; Spell C
         dw $A018        ; Spell D
         dw $AC18        ; Spell E
         dw $B818        ; Bonus

; Draw selected esper's info
C35FF4:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C3634C     ; Text pointer
         JSR C30326      ; Do "Learn.Rate"
         LDY #C36343     ; Text pointer
         JSR C30326      ; Draw "Skill"
         LDA $99         ; Viewed esper
         JSR C35BCD      ; Choose palette
         LDY #$4451      ; Tilemap ptr			=== SNES: Shifted a row upward but makes no difference (compensated by HDMA?) (did they wrongly do -40h instead of +40h?)
         JSR C335E1      ; Set pos, WRAM
         TDC             ; ...
         LDA $99         ; Viewed esper
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         TAX             ; Index it
         LDY #$0008      ; Letters: 8
C36019:  LDA $ED750E,X   ; Esper name char		=== SNES: $E6F6E1
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C36019      ; Loop till last
         STZ $2180       ; End string
         JSR C387B9      ; Draw esper name

; Fork: Draw spell data
C3602A:  TDC             ; Clear A
         LDA $4B         ; Selected slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Esper in slot
         STA $4202       ; Set multiplicand
         LDA #$0B        ; Esper data size
         STA $4203       ; Set multiplier
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$0012      ; Y: 18			=== SNES: 17
         STY $F5         ; Memorize it
         REP #$20        ; 16-bit A
         LDA $4216       ; Product
         TAX             ; Index it
C36049:  SEP #$20        ; 8-bit A
         LDA $E6F567,X   ; Learning rate		=== SNES: $D86E00
         STA $E0         ; Memorize it
         INX             ; Index +1
         LDA $E6F567,X   ; Spell			=== SNES: $D86E00
         STA $E1         ; Memorize it
         INX             ; Index +1
         PHX             ; Save index
         LDX #$0005      ; X: 5
         LDY $F5         ; Y position
         LDA $E1         ; Spell
         PHA             ; Preserve it
         JSR C36136      ; Draw spell, rate
         LDX #$0018      ; X: 24
         LDY $F5         ; Y position
         PLA             ; Spell
         STA $E1         ; Restore it
         JSR C360D9      ; Draw percentage
         PLX             ; Spell data index
         REP #$20        ; 16-bit A
         INC $F5         ; Y position +1
         INC $F5         ; Y position +1
         LDA $F5         ; Y position
         CMP #$001C      ; Done 5 spells?		=== SNES: #$001B (because of base Y difference above)
         BNE C36049      ; Loop if not

; Fork: Draw esper bonus message
C3607E:  SEP #$20        ; 8-bit A
         LDA $E6F567,X   ; Esper bonus			=== SNES: $D86E00
         CMP #$FF        ; None?
         BEQ C360BC      ; Blank if so
         STA $4202       ; Set multiplicand
         LDA #$08        ; Text length			=== SNES: 9
         STA $4203       ; Set multiplier
         LDY #$4753      ; Tilemap ptr			=== SNES shifts it up but makes no difference (compensated by HDMA?) (did they wrongly do -40h instead of +40h?)
         JSR C335E1      ; Set pos, WRAM
         LDX $00         ; Char index: 0
C36098:  LDA.L C36357,X  ; "At..." char
         STA $2180       ; Add to string
         INX             ; Point to next
         CPX #$000B      ; Done all 11?			=== SNES: 14
         BNE C36098      ; Loop if not
         LDX $4216       ; Index product
         LDY #$0008      ; Letters: 8			=== SNES: 9
C360AB:  LDA $CFFEAE,X   ; Bonus char
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C360AB      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Blank esper bonus message
C360BC:  LDY #$4753      ; Tilemap ptr			=== SNES: See similar case above
         JSR C335E1      ; Set pos, WRAM
         LDY #$0013      ; Letters: 19			=== SNES: 23
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C360CD:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C360CD      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 19 spaces		=== SNES: 23

; Draw spell's mastery percentage for esper data menu
C360D9:  JSR C36195      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA $E1         ; Spell
         CMP #$FF        ; None?
         BEQ C36126      ; Blank if so
         JSR C35771      ; Spell mastery
         CMP #$FF        ; Fully learned?
         BEQ C36117      ; Branch if so
         PHA             ; Save mastery
         LDA #$FF        ; Space char
         STA $2180       ; Add to string
         PLA             ; Spell mastery
         JSR C30563      ; Turn into text
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string
C3610C:  LDA #$CD        ; Char: "%"
         STA $2180       ; Add to string
C36111:  STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: Draw "100%"
C36117:  LDA #$54        ; Char: "1"			=== SNES: Different tile number
         STA $2180       ; Add to string
         LDA #$53        ; Char: "0"			=== SNES: Different tile number
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         BRA C3610C      ; Add "%"; draw

; Fork: Blank percentage
C36126:  LDA #$FF        ; Space char
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         BRA C36111      ; Draw 4 spaces

; Draw spell's name and learning rate
C36136:  JSR C36195      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
C36142:  JSR C35692      ; Define source
         LDA $E1         ; Spell
         CMP #$FF        ; None?
         BEQ C3617E      ; Blank if so
         JSR C38BF2      ; Load name
         LDX #$9E90      ; 7E/9E90			=== SNES: 7E/9E92 (longer names)
         STX $2181       ; Set WRAM LBs
         LDA #$CF        ; Char: ":"			=== SNES: Different tile number
         STA $2180       ; Add to string
         LDA #$FF        ; Space char
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string		%%%
         LDA #$D7        ; Char: "×"
         STA $2180       ; Add to string
         LDA $E0         ; Learning rate
         JSR C30563      ; Turn into text
         LDA $F8         ; Tens digit
         STA $2180       ; Add to string
         LDA $F9         ; Ones digit
         STA $2180       ; Add to string
         STZ $2180       ; End string
         JMP C387B9      ; Draw string

; Fork: No spell
C3617E:  LDY #$000D      ; Spaces: 13			=== SNES: 15
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Space char
C36189:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C36189      ; Loop till last
         STZ $2180       ; End string
         JMP C387B9      ; Draw 13 spaces		=== SNES: 15

; Compute position into BG1 tilemap B
C36195:  REP #$20        ; 16-bit A
         TYA             ; Y position
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         ASL A           ; x64
         STA $E7         ; Memorize it
         TXA             ; X position
         ASL A           ; Double it
         CLC             ; ...
         ADC $E7         ; Add Y x64
         ADC #$4049      ; Add base adr
         TAX             ; Put in X...
         SEP #$20        ; 8-bit A...
         RTS

; Load esper's info for display
C361AC:  TDC             ; Clear A...
         LDA $99         ; Chosen esper
         STA $7EAB8D     ; Add to list
         LDA $4B         ; Chosen slot...
         TAX             ; Index it...
         LDA $7E9D89,X   ; Chosen esper...
         STA $4202       ; Set multiplicand
         LDA #$0B        ; Esper data size
         STA $4203       ; Set multiplier
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDY #$0001      ; Spell slot: 1
         REP #$20        ; 16-bit A
         LDA $004216     ; Product
         TAX             ; Index it
         SEP #$20        ; 8-bit A
C361D3:  INX             ; Skip Learn.Rate
         LDA $E6F567,X   ; Spell taught			=== SNES: $D86E00
         STA $AB8D,Y     ; Add to list
         INX             ; ROM index +1
         INY             ; RAM index +1
         CPY #$0006      ; Done 5 spells?
         BNE C361D3      ; Loop if not
         LDA $E6F567,X   ; Level up bonus		=== SNES: $D86E00
         STA $AB93       ; Add to list
         PLB             ; Restore DB
         RTS

; Load description for esper data menu
C361EB:  LDX #$9EC9      ; 7E/9EC9
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         LDA $4B         ; Cursor row
         TAX             ; Index it
         LDA $7EAB8D,X   ; Slot content
         CMP #$FF        ; Empty slot?
         BEQ C36229      ; Blank if so
         PHA             ; Memorize it
         JSR C36233      ; Load pointers
         PLA             ; Slot content
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAY             ; Index it
         LDA [$E7],Y     ; Relative ptr
         TAY             ; Index it
         SEP #$20        ; 8-bit A
C3620B:  LDA [$EB],Y     ; Text character
         BEQ C36215      ; Branch if 00h
         STA $2180       ; Add to string
         INY             ; Index +1
         BRA C3620B      ; Do next char

; Fork: Check if terminator
C36215:  DEY             ; Index -1
         LDA [$EB],Y     ; Previous char
         INY             ; Index +1
         CMP #$1C        ; Command 1C?
         BEQ C3622D      ; Branch if so
         CMP #$1D        ; Command 1D?
         BEQ C3622D      ; Branch if so
         CMP #$1E        ; Command 1E?
         BEQ C3622D      ; Branch if so
         CMP #$1F        ; Command 1F?
         BEQ C3622D      ; Branch if so
C36229:  STZ $2180       ; End string
         RTS

; Fork: Resume past control code
C3622D:  STZ $2180       ; Add 00h to msg
         INY             ; Index +1
         BRA C3620B      ; Do next char

; Load description pointers for esper data menu
C36233:  LDA $4B         ; On esper name?
         BEQ C36261      ; Branch if so
         CMP #$06        ; On bonus?
         BEQ C3624E      ; Branch if so

; Fork: Magic effect
C3623B:  LDX #$F690      ; E6/F690			=== SNES: D8/CF80
         STX $E7         ; Set ptr loc LBs
         LDX #$C9A0      ; D8/C9A0
         STX $EB         ; Set text loc LBs
         LDA #$E6        ; Bank: E6			=== SNES: D8
         STA $E9         ; Set ptr loc HB
         LDA #$D8        ; Bank: D8
         STA $ED         ; Set text loc HB
         RTS

; Fork: Level up bonus
C3624E:  LDX #$FF6E      ; CF/FFD0			=== SNES: ED/FFD0
         STX $E7         ; Set ptr loc LBs
         LDX #$F600      ; D0/F600			=== SNES: ED/FE00
         STX $EB         ; Set text loc LBs
         LDA #$CF        ; Bank: CF			=== SNES: ED
         STA $E9         ; Set ptr loc HB
         LDA #$D0        ; Bank: D0			=== SNES: ED
         STA $ED         ; Set text loc HB
         RTS

; Fork: Esper effect
C36261:  LDX #$FE40      ; CF/FE40
         STX $E7         ; Set ptr loc LBs
         LDX #$CDA0      ; D8/CDA0			=== SNES: CF/3940
         STX $EB         ; Set text loc LBs
         LDA #$CF        ; Bank: CF
         STA $E9         ; Set ptr loc HB
         LDA #$D8        ; Bank: D8			=== SNES: CF
         STA $ED         ; Set text loc HB
         RTS

; Tile attributes for Blitz inputs
C36274:  dw $0000        ; Terminator
         dw $0000        ; Bogus; for A
         dw $0000        ; Bogus; for B
         dw $2037        ; X				=== SNES: Different tile numbers (X, Y, L, R)
         dw $2038        ; Y
         dw $202B        ; L
         dw $2031        ; R
         dw $20D6        ; Down-left
         dw $A0D4        ; Down
         dw $60D6        ; Down-right
         dw $20D5        ; Right
         dw $C0D6        ; Up-right
         dw $20D4        ; Up
         dw $A0D6        ; Up-left
         dw $60D5        ; Left

; Text pointers for Skills menu (unused)
C36292:  dw C362A0                      ; Espers
         dw C362A8                      ; Magic
         dw C362AE                      ; SwdTech
         dw C362B7                      ; Blitz
         dw C362C0                      ; Lore
         dw C362C9                      ; Rage
         dw C362D0                      ; Dance

; Positioned text for Skills menu
C362A0:  dw $78CD : db |げんじゅう[end]|	; Espers	=== SNES: +40h as no diacritics (also below)
C362A8:  dw $794D : db |まほう[end]|	; Magic
C362AE:  dw $7A4D : db |ひっさつけん[end]|	; SwdTech
C362B7:  dw $7ACD : db |ひっさつわざ[end]|	; Blitz
C362C0:  dw $7B4D : db |おぼえたわざ[end]|	; Lore
C362C9:  dw $7BCD : db |あばれる[end]|	; Rage
C362D0:  dw $7C4D : db |おどり[end]|	; Dance

; Text pointers for Skills menu
C362D6:  dw C36324                      ; LV
         dw C36329                      ; HP
         dw C3632E                      ; MP

; Positioned spaces for blanking diacritics in skill submenu title	%%%
C362DC:  dw $80CD : db "      ",$00

; Positioned text for Skills submenus				=== SNES: Title is in opposite corner
C362E5:  dw $810D : db "MP…   ",$00				=== SNES: "MP…" (really "MP.." here); has one more space
C362EE:  dw $80CD : db |おぼえたわざ[end]|	; Lore
C362F7:  dw $80CD : db |あばれる  [end]|	; Rage
C36300:  dw $80CD : db |おどり   [end]|	; Dance
C36309:  dw $80CD : db |げんじゅう [end]|	; Espers
C36312:  dw $80CD : db |ひっさつわざ[end]|	; Blitz
C3631B:  dw $80CD : db |ひっさつけん[end]|	; SwdTech
C36324:  dw $422D : db "LV",$00
C36329:  dw $42AD : db "HP",$00
C3632E:  dw $432D : db "MP",$00
C36333:  dw $42BB : db "/",$00
C36337:  dw $433B : db "/",$00
C3633B:           : db |がもっています[end]|	; has it!
C36343:  dw $4475 : db |じゅくれんど[end]|	; Skill			=== SNES position differs
C3634C:  dw $4463 : db |おぼえるスピード[end]|	; Learn.Rate		=== SNES position differs (meant +40h instead of -40h?)
C36357:           : db |レベルアップのときに |	; At level up...	=== SFC has no "..."

; Draw and upload Status menu, create portrait
C36362:  JSR C36374      ; Draw main windows
         JSR C3641E      ; Draw Gogo's panel
         JSR C36399      ; Draw blue text
         JSR C365E3      ; Draw actor info
         JSR C363D4      ; Upload tilemaps
         JMP C36802      ; Create portrait

; Draw windows for non-shifted Status menu
C36374:  JSR C371A9      ; Clear BG1 map A
         JSR C371B7      ; Clear BG1 map D
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         JSR C371DA      ; Clear BG3 map C
         JSR C371DF      ; Clear BG3 map D
         LDY #C365D7     ; C3/65D7
         JSR C303C4      ; Draw main window
         LDY #C365CF     ; C3/65CF
         JSR C303C4      ; Draw title window
         LDY #C365D3     ; C3/65D3
         JSR C303C4      ; Draw cmd window
         RTS

; Draw blue text and non-blue symbols in Status menu
C36399:  JSR C3639E      ; LV, HP, MP, %, /
         BRA C363B9      ; Rest of blue text

; Draw LV, HP, MP, and non-blue symbols in Status menu
C3639E:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C36A9E     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3712C      ; Draw 2x / and %
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C36A98     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         RTS

; Draw all blue text in Status menu except LV, HP, and MP
C363B9:  LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C36A80     ; Text ptrs loc
         LDY #$0018      ; Strings: 12			=== SNES: 15 (some leaders are merged with stats names)
         JSR C3712C      ; Draw Vigor, etc.
         LDA #$2C        ; ...
         STA $29         ; ...
         LDX #C36AA6     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw Speed, etc.
         RTS

; Upload tilemaps for Status menu
C363D4:  JSR C30EBD      ; Upload BG2 A+B
         JSR C30E93      ; Upload BG1 A+B
         JSR C30ED9      ; Upload BG3 A+B
         JMP C30EE7      ; Upload BG3 C+D

; Handle member switching in Status menu
C363E0:  JSR C3639E      ; Draw "MP" + "/"
         JSR C365E3      ; Draw actor info
         JSR C367F8      ; Create portrait
         LDY #$0000      ; $0000 = BG1a
         STY $14         ; Set VRAM ptr A
         LDY #$3849      ; 7E/3849
         STY $16         ; Set src-a LBs
         LDY #$0800      ; Bytes: 2048
         STY $12         ; Set src-a size
         LDY #$4000      ; $4000 = BG3a
         STY $1B         ; Set VRAM ptr B
         LDY #$7849      ; 7E/7849
         STY $1D         ; Set src-b LBs
         LDY #$0800      ; Bytes: 2048
         STY $19         ; Set src-b size
         JSR C3121B      ; Swap portraits
         JSR C313D3      ; Trigger NMI
         LDY $00         ; Null value
         STY $1B         ; Dequeue BG3a
         LDY #$4800      ; $4800 = BG3c
         STY $14         ; Set VRAM ptr
         LDY #$8849      ; 7E/8849
         STY $16         ; Set src LBs
         JMP C313D3      ; Upload BG3c

; Draw Gogo's list of available commands, prepare portrait hiding
C3641E:  LDX #$9E09      ; 7E/9E09
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A

; Fork: Compile everyone's commands, exclude guests and dead Shadow
C36425:  TAX             ; 1st: Terra
C36426:  PHX             ; Save char slot
         REP #$20        ; 16-bit A
         TXA             ; Actor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $1EDC       ; Eligible actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C36458      ; Skip if not
         REP #$20        ; ...
         LDA.L C370DB,X  ; Actor's address
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA $0016,X     ; Command 1
         STA $2180       ; Add to list
         LDA $0017,X     ; Command 2
         STA $2180       ; Add to list
         LDA $0018,X     ; Command 3
         STA $2180       ; Add to list
         LDA $0019,X     ; Command 4
         STA $2180       ; Add to list
         BRA C36468      ; Do next actor
C36458:  SEP #$20        ; 8-bit A
         LDA #$FF        ; Command: None
         STA $2180       ; Set command 1
         STA $2180       ; Set command 2
         STA $2180       ; Set command 3
         STA $2180       ; Set command 4
C36468:  PLX             ; Actor slot
         INX             ; Actor slot +1
         CPX #$0010      ; Done 16 actors?
         BNE C36426      ; Loop if not

; Fork: Delete duplicates
C3646F:  TDC             ; Clear A
         TAX             ; Cmd slot: 1
C36471:  PHX             ; Save cmd slot
         LDA $7E9E09,X   ; Available cmd
C36476:  CMP $7E9E0A,X   ; Duplicate?
         BNE C36484      ; Branch if not
         PHA             ; Save command
         LDA #$FF        ; Command: None
         STA $7E9E0A,X   ; Clear duplicate
         PLA             ; Battle command
C36484:  INX             ; Cmd slot +1
         CPX #$0040      ; Done 16 x 4?
         BNE C36476      ; Loop if not
         PLX             ; Base cmd slot
         INX             ; Cmd slot +1
         CPX #$0040      ; Done 16 x 4?
         BNE C36471      ; Loop if not

; Fork: Build final command list
C36491:  LDX #$9D8A      ; 7E/9D8A
         STX $2181       ; Set WRAM LBs
         LDA #$FF        ; Cmd: Empty
         STA $2180       ; Add to list
         TDC             ; Clear A
         TAX             ; Cmd slot: 1
         TAY             ; Cmd count: 0
C3649F:  TDC             ; ...
         PHX             ; Save cmd slot
         LDA $7E9E09,X   ; Available cmd
         BMI C364BD      ; Skip if none
         CMP #$12        ; Mimic?
         BEQ C364BD      ; Skip if so
         STA $E0         ; Memorize it
         ASL A           ; Double it
         TAX             ; Index it
         LDA $CFFE00,X   ; Properties
         AND #$01        ; Gogo can use?
         BEQ C364BD      ; Skip if not
         LDA $E0         ; Command
         STA $2180       ; Add to list
         INY             ; Cmd count +1
C364BD:  PLX             ; Cmd slot
         INX             ; Cmd slot +1
         CPX #$0040      ; Done 16 x 4?
         BNE C3649F      ; Loop if not
         INY             ; Cmd count +1
         TYA             ; Put it in A
         STA $7E9D89     ; Set list size

; Fork: Load window layout for command list
C364CA:  LDX #$AA8D      ; 7E/AA8D
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         TAX             ; Index: 0
C364D2:  LDA.L C365DB,X  ; Window data
         STA $2180       ; Save in WRAM
         INX             ; Index +1
         CPX #$0008      ; End of table?
         BNE C364D2      ; Loop if not

; Fork: Draw both segments of command window
C364DF:  TYA             ; Command count
         STA $E2         ; Memorize it
         CLC             ; Prepare ADC
         ADC $E2         ; x2
         ADC $E2         ; x3
         AND #$FE        ; -1 if odd
         BEQ C364ED      ; Branch if no cmd
         INC A           ; +1
         INC A           ; +1
C364ED:  LSR A           ; ÷2
         STA $7EAA90     ; Set L-Win heigth
         STA $7EAA94     ; Set R-Win heigth
         LDY #$AA8D      ; 7E/AA8D
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JSR C303C8      ; Draw left box
         LDY #$AA91      ; 7E/AA91
         LDA #$7E        ; ...
         STA $E9         ; ...
         JSR C303C8      ; Draw right box

; Fork: Draw command list, prepare portrait hiding
C3650A:  LDA $7E9D89     ; List size
         STA $E5         ; Memorize it
         STZ $E6         ; Clear HB
         TDC             ; Clear A
         TAX             ; Cmd slot: 1
         LDY #$808B      ; Tilemap ptr			=== SNES: +40h as no diacritics; shifted lefward as longer names
C36517:  PHX             ; Save cmd slot
         PHY             ; Save position
         LDA $7E9D8A,X   ; Available cmd
         JSR C36534      ; Draw cmd name
         PLY             ; Text position
         REP #$20        ; 16-bit A
         TYA             ; Put in A
         CLC             ; Prepare ADC
         ADC #$0080      ; +2 rows down
         TAY             ; Put in Y
         SEP #$20        ; 8-bit A
         PLX             ; Cmd slot
         INX             ; Cmd slot +1
         CPX $E5         ; End of list?
         BNE C36517      ; Loop if not
         JMP C365A6      ; Set hiding spot

; Draw battle command name, ignore modifiers
C36534:  PHA             ; Save command
         JSR C335E1      ; Set pos, WRAM
         PLA             ; Battle command
         BMI C36565      ; Blank if none
         JMP C36543      ; Draw cmd name

; Draw battle command name, apply modifiers
C3653E:  JSR C36782      ; Apply modifiers
         BMI C36565      ; Blank if no cmd
C36543:  JSR C3657B      ; Pick a palette

         PHA             ; Save command
         ASL A           ; x2
         ASL A           ; x4
         STA $E0         ; Memorize it
         PLA             ; Command
         ASL A           ; x2
         CLC             ; ...
         ADC $E0         ; x6

         TAX             ; Index it
         LDY #$0006      ; Letters: 6			=== SNES: 7
C36554:  LDA $ECE300,X   ; Letter			=== SNES: $D8CEA0
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C36554      ; Loop till last
C3655F:  STZ $2180       ; End string
         JMP C387B9      ; Draw cmd name

; Fork: Blank command slot
C36565:  LDA #$FF        ; Space char
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string
         STA $2180       ; Add to string

         BRA C3655F      ; Draw 6 spaces		=== SNES: 7

; Select a palette for battle command
C3657B:  PHA             ; Save command
         CMP #$0B        ; Runic?
         BEQ C36590      ; Branch if so
         CMP #$07        ; SwdTech?
         BEQ C3659A      ; Branch if so
C36584:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         PLA             ; Command
         RTS

; Fork: Set to gray
C3658A:  LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         PLA             ; Command
         RTS

; Fork: Handle Runic
C36590:  LDA $11DA       ; R-Hand can Runic?
         ORA $11DB       ; Or L-Hand?
         BPL C3658A      ; Gray out if not
         BRA C36584      ; Use user's color

; Fork: Handle SwdTech
C3659A:  LDA $11DA       ; R-Hand flags
         ORA $11DB       ; Add L-Hand's
         BIT #$02        ; Can use SwdTech?
         BEQ C3658A      ; Gray out if not
         BRA C36584      ; Use user's color

; Set a section of Status menu to mask wrapping Gogo portrait
C365A6:  LDX #$61CA      ; Tilemap ptr
         STX $E7         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set dst HB
         LDX #$0006      ; Rows left: 6
C365B2:  TDC             ; Clear A
         TAY             ; Map index: 0
         LDA #$3D        ; Pal 7, priority
C365B6:  STA [$E7],Y     ; Set attributes
         INY             ; Index +1
         INY             ; Index +1
         CPY #$0012      ; Done 9 tiles?
         BNE C365B6      ; Loop if not
         REP #$20        ; 16-bit A
         LDA $E7         ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         STA $E7         ; Save changes
         SEP #$20        ; 8-bit A
         DEX             ; One less row
         BNE C365B2      ; Loop till last
         RTS

; Window layout for Status menu
C365CF:  dw $588B,$0105  ; 07x03 at $588B (Title)	=== SNES: Expanded rightward
C365D3:  dw $5AEB,$0609  ; 11x08 at $5AEB (Commands)
C365D7:  dw $588B,$181C  ; 30x26 at $588B (Main)
C365DB:  dw $58C7,$1200  ; 02x20 at $58C7 (Gogo, L part)
C365DF:  dw $6087,$1207  ; 09x20 at $6087 (Gogo, R part)

; Draw actor info in Status menu
C365E3:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C365EB,X)  ; Draw info

; Jump table for the above
C365EB:  dw C365F3       ; Member 1
         dw C365FD       ; Member 2
         dw C36607       ; Member 3
         dw C36611       ; Member 4

; Draw member 1's info in Status menu
C365F3:  LDX $6D         ; Actor address
         STX $67         ; Memorize it
         TDC             ; ...
         LDA $69         ; Actor
         JMP C36618      ; Draw info

; Draw member 2's info in Status menu
C365FD:  LDX $6F         ; Actor address
         STX $67         ; Memorize it
         TDC             ; ...
         LDA $6A         ; Actor
         JMP C36618      ; Draw info

; Draw member 3's info in Status menu
C36607:  LDX $71         ; Actor address
         STX $67         ; Memorize it
         TDC             ; ...
         LDA $6B         ; Actor
         JMP C36618      ; Draw info

; Draw member 4's info in Status menu
C36611:  LDX $73         ; Actor address
         STX $67         ; Memorize it
         TDC             ; ...
         LDA $6C         ; Actor
C36618:  JSL $C20006     ; Load properties
         LDY $67         ; Actor's address
         JSR C3A1D7      ; Set Bat.Pwr mode
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDA $11A6       ; Vigor
         JSR C30563      ; Turn into text
         LDX #$7EE1      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $11A4       ; Speed
         JSR C30563      ; Turn into text
         LDX #$7F61      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $11A2       ; Stamina
         JSR C30563      ; Turn into text
         LDX #$7FE1      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $11A0       ; Mag.Pwr
         JSR C30563      ; Turn into text
         LDX #$8861      ; Text position
         JSR C30543      ; Draw 3 digits
         JSR C39B5A      ; Define Bat.Pwr
         LDA $11AC       ; ...
         CLC             ; ...
         ADC $11AD       ; ...
         STA $F3         ; ...
         TDC             ; ...
         ADC #$00        ; ...
         STA $F4         ; ...
         JSR C305B1      ; Turn into text
         LDX #$7E7D      ; Text position
         JSR C30509      ; Draw 3 digits
         LDA $11BA       ; Defense
         JSR C30563      ; Turn into text
         LDX #$7EFD      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $11A8       ; Evade
         JSR C30563      ; Turn into text
         LDX #$7F7D      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $11BB       ; Mag.Def
         JSR C30563      ; Turn into text
         LDX #$7FFD      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $11AA       ; MBlock
         JSR C30563      ; Turn into text
         LDX #$887D      ; Text position
         JSR C30543      ; Draw 3 digits
         LDY #$394F      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDY #$395D      ; Text position		=== SNES: +40h as no diacritics
         JSR C33580      ; Draw actor class		=== SNES: No class
         LDY #$3971      ; Text position		=== SNES: +40h as no diacritics
         JSR C335AE      ; Draw held esper
         JSR C36758      ; Draw commands
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C366EC     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
         LDX $67         ; Actor's address
         LDA $0011,X     ; Experience LB
         STA $F1         ; Memorize it
         LDA $0012,X     ; Experience MB
         STA $F2         ; Memorize it
         LDA $0013,X     ; Experience HB
         STA $F3         ; Memorize it
         JSR C30605      ; Turn into text
         LDX #$7CD7      ; Text position
         JSR C30526      ; Draw 8 digits
         JSR C366F6      ; Get needed exp
         JSR C30605      ; Turn into text
         LDX #$7DD7      ; Text position
         JSR C30526      ; Draw 8 digits
         STZ $47         ; Ailments: Off
         JSR C3121B      ; Hide ail. icons
         JMP C368A4      ; Display status

; Tilemap pointers for stats in Status menu
C366EC:  dw $3A27        ; Level
         dw $3A63        ; HP
         dw $3A6D        ; Max HP
         dw $3AA3        ; MP
         dw $3AAD        ; Max MP

; Calculate experience needed to level up
C366F6:  LDX $67         ; Actor's address
         TDC             ; ...
         LDA $0008,X     ; Level
         CMP #$63        ; 99?
         BEQ C36719      ; Branch if so
         JSR C36720      ; Get needed XP
         LDX $67         ; Actor's address
         SEC             ; Prepare SBC
         LDA $F1         ; Needed XP LB
         SBC $0011,X     ; Deduct XP LB
         STA $F1         ; Save changes
         REP #$20        ; 16-bit A
         LDA $F2         ; Needed XP HBs
         SBC $0012,X     ; Deduct XP HBs
         STA $F2         ; Save changes
         SEP #$20        ; 8-bit A
         RTS

; Fork: Zero experience needed
C36719:  TDC             ; Clear A
         TAX             ; Clear X
         STX $F1         ; Needed XP LBs
         STZ $F3         ; Needed XP HB
         RTS

; Calculate total experience needed to level up
C36720:  ASL A           ; Level x2
         STA $EB         ; Set counter
         TDC             ; Clear A
         TAX             ; 1st: Level 1
         STX $F1         ; Total LBs: 0
         STX $F3         ; Total HBs: 0
         STZ $EC         ; Level HB: 0
C3672B:  CLC             ; ...
         LDA $ED8220,X   ; Needed XP LB
         ADC $F1         ; Add total LB
         STA $F1         ; Set total LB
         INX             ; Index +1
         LDA $ED8220,X   ; Needed XP HB
         ADC $F2         ; Add total MB+C
         STA $F2         ; Set total MB
         TDC             ; Zero A
         ADC $F3         ; Add total HB+C
         STA $F3         ; Set total HB
         INX             ; Index +1
         CPX $EB         ; At current LV?
         BNE C3672B      ; Loop if not

; Fork: Octuple total to get true value
C36747:  REP #$20        ; 16-bit A
         ASL $F1         ; Total LBs x2
         ROL $F3         ; HBs x2 + C
         ASL $F1         ; Total LBs x2
         ROL $F3         ; HBs x2 + C
         ASL $F1         ; Total LBs x2
         ROL $F3         ; HBs x2 + C
         SEP #$20        ; 8-bit A
         RTS

; Draw actor's command list in Status menu
C36758:  LDY #$7BB1      ; Tilemap ptr			=== SNES: +40h as no diacritics (all 4 commands)
         JSR C335E1      ; Set pos/WRAM/Y
         JSR C3653E      ; Draw command 1
         LDY #$7C31      ; Tilemap ptr
         JSR C335E1      ; Set pos/WRAM/Y
         INY             ; Point to cmd 2
         JSR C3653E      ; Draw command 2
         LDY #$7CB1      ; Tilemap ptr
         JSR C335E1      ; Set pos/WRAM/Y
         INY             ; Point to cmd 2
         INY             ; Point to cmd 3
         JSR C3653E      ; Draw command 3
         LDY #$7D31      ; Tilemap ptr
         JSR C335E1      ; Set pos/WRAM/Y
         INY             ; Point to cmd 2
         INY             ; Point to cmd 3
         INY             ; Point to cmd 4
         JMP C3653E      ; Draw command 4

; Handle battle command modifiers
C36782:  LDA $0016,Y     ; Command
         CMP #$02        ; Magic?
         BNE C36794      ; Branch if not
         PHY             ; Save index
         JSR C30D96      ; Can use magic?
         BCS C36793      ; Branch if so
         PLY             ; Actor's address
         LDA #$FF        ; Command: None
         RTS

; Fork: Morph
C36793:  PLY             ; Actor's address
C36794:  LDA $0016,Y     ; Command
         CMP #$03        ; Morph?
         BNE C367A5      ; Branch if not
         LDA $1DD1       ; Event flags
         BIT #$04        ; Unlocked Morph?
         BNE C367A5      ; Branch if so
         LDA #$FF        ; Command: None
         RTS

; Fork: Leap
C367A5:  LDA $0016,Y     ; Command
         CMP #$11        ; Leap?
         BNE C367B6      ; Branch if not
         LDA $11E4       ; Veldt flags
         BIT #$04        ; Can show Leap?
         BNE C367B6      ; Branch if so
         LDA #$FF        ; Command: None
         RTS

; Fork: Dance
C367B6:  LDA $0016,Y     ; Command
         CMP #$13        ; Dance?
         BNE C367C5      ; Branch if not
         LDA $1D4C       ; Known Dances
         BNE C367C5      ; Branch if any
         LDA #$FF        ; Command: None
         RTS

; Fork: Relic effects
C367C5:  LDA $0016,Y     ; Command
         STA $E0         ; Memorize it
         TDC             ; Clear A
         TAX             ; 1st: Capture
         LDA $11D6       ; Relic effects
         AND #$7C        ; Cmd upgrades
         ASL A           ; Shift bits
C367D2:  ASL A           ; Got current?
         BCC C367DF      ; Skip if not
         PHA             ; Save upgrades
         LDA.L C367EE,X  ; Cmd to switch
         CMP $E0         ; Current cmd?
         BEQ C367E8      ; Replace if so
         PLA             ; Cmd upgrades
C367DF:  INX             ; Index +1
         CPX #$0005      ; Done Fight?
         BNE C367D2      ; Loop if not
         LDA $E0         ; Original cmd
         RTS

; Fork: Replace command
C367E8:  PLA             ; Clean stack
         LDA.L C367F3,X  ; New command
         RTS

; Commands to upgrade
C367EE:  db $05          ; Steal
         db $0F          ; Slot
         db $0D          ; Sketch
         db $02          ; Magic
         db $00          ; Fight

; Command upgrades
C367F3:  db $06          ; Capture
         db $18          ; GP Rain
         db $0E          ; Control
         db $17          ; X Magic
         db $16          ; Jump

; Replace portrait in Status menu after actor swap
C367F8:  TDC             ; Clear A
         LDA $60         ; Queue index
         TAX             ; Index it
         LDA #$FF        ; Null value
         STA $7E35C9,X   ; Hide old one

; Create portrait by upper-left corner
C36802:  JSR C36823      ; Queue OAM fn
         JMP C3682F      ; Init sprite

; Create portrait for Equip or Relic menu
C36808:  JSR C36823      ; Queue OAM fn
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA #$00C8      ; X: 200
         STA $33CA,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         TDC             ; ...
         LDA $28         ; Member slot
         TAY             ; Put in Y





         JSR C36844      ; Set Y/ptr/timer		=== SNES sets these individually
         PLB             ; Restore DB
         RTS

; Create portrait A
C36823:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         TXA             ; Queue index
         STA $60         ; Set sprite's
         RTS

; Place portrait by upper-left corner, set pose timer
C3682F:  PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         LDA $28         ; Member slot
         TAY             ; Put in Y
         JSR C30B5C      ; Set X position
         TDC             ; ...
         LDA $28         ; ...
         TAY             ; ...
         JSR C36844      ; Set Y/ptr/timer
         PLB             ; Restore DB
         RTS

; Initialize variables for portrait by either upper corner	=== SNES: Upper-left corner only
C36844:  JSR C30B37      ; Load anim ptr
         REP #$20        ; 16-bit A
         LDA #$0030      ; Y: 48				=== SNES: 56
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         JMP C31271      ; Set pose timer

; Set to condense BG3 text in Status menu
C36854:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C36873     ; C3/6873
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Text shifting table for the above
C36873:  db $27,$00,$00  ; Status
         db $0C,$04,$00  ; Cmd choice A
         db $0C,$08,$00  ; Cmd choice B
         db $0C,$0C,$00  ; Cmd choice C
         db $0C,$10,$00  ; Cmd choice D
         db $0C,$14,$00  ; Command A
         db $0C,$18,$00  ; Command B
         db $0C,$1C,$00  ; Command C
         db $0C,$20,$00  ; Command D
         db $0C,$24,$00  ; Needed exp.
         db $0C,$28,$00  ; Bat.Pwr
         db $0C,$2C,$00  ; Defense
         db $0C,$30,$00  ; Evade
         db $0C,$34,$00  ; Mag.Def
         db $0C,$38,$00  ; MBlock
         db $0C,$3C,$00  ; Nothing
         db $00          ; End

; Display status effects in Status menu
C368A4:  LDY #$38DD      ; Text position		=== SNES: Lower (same height as actor name instead of higher because there's no class)
         LDX #$1050      ; Icon position		=== SNES: Same change as above
         STX $E7         ; Set as current
         JSR C335E1      ; Set text pos
         LDA $0014,Y     ; Wounded?
         BMI C36930      ; Draw it if so
         AND #$70        ; Clear/Imp/Pet
         STA $E1         ; Memorize them
         LDA $0014,Y     ; Status effects
         AND #$07        ; Dark/Zom/Poison
         ASL A           ; Put in b1-b3
         STA $E2         ; Memorize them
         LDA $0015,Y     ; Status effects
         AND #$80        ; Isolate Float
         ORA $E1         ; Add Clear, etc.
         ORA $E2         ; Add Dark, etc.
         STA $E1         ; ...
         BEQ C3692A      ; Blank if none
         STZ $F1         ; GFX index LB: 0
         STZ $F2         ; GFX index HB: 0
         LDX #$0007      ; Status left: 7
C368D4:  PHX             ; Save counter
         ASL A           ; Got current?
         BCC C3691E      ; Skip if not
         PHA             ; Save status
         LDA #$03        ; Min slot: 24
         LDY #C382C9     ; C3/82C9
         JSR C311DE      ; Queue icon OAM
         LDA #$01        ; Pans with BG1
         STA $7E364A,X   ; Set OBJ flags
         TDC             ; Anim mode: 0
         STA $7E3649,X   ; Set icon's
         TXY             ; Queue index
         LDX $F1         ; GFX index
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $D8ECAF,X   ; Anim table ptr		=== SNES: $D8EC25,X
         STA $32C9,Y     ; Set icon's
         SEP #$20        ; 8-bit A
         LDA $E7         ; X position
         STA $33CA,Y     ; Set icon's
         LDA $E8         ; Y position
         STA $344A,Y     ; Set icon's
         TDC             ; Clear A
         STA $33CB,Y     ; No use...
         STA $344B,Y     ; No use...
         LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set ptr HB
         PLB             ; Restore DB
         CLC             ; Prepare ADC
         LDA #$0A        ; Modifier: +10
         ADC $E7         ; Add current X
         STA $E7         ; Set current X
         PLA             ; Status effects
C3691E:  INC $F1         ; GFX index +1
         INC $F1         ; GFX index +1
         PLX             ; Status left
         DEX             ; One less left
         BNE C368D4      ; Loop till last
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
C3692A:  JSR C3694F      ; Load 8 spaces
         JMP C387B9      ; Blank "Wounded"

; Fork: Draw "Wounded"
C36930:  LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Index: 0
C36938:  LDA.L C337E3,X  ; Letter
         STA $2180       ; Add to string
         INX             ; Point to next
         CPX #$0008      ; Copied 8?
         BNE C36938      ; Loop if not
         STZ $2180       ; End string
         LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         JMP C387B9      ; Draw string

; Create blank string for erasing "Wounded"
C3694F:  LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Spaces: 0
         LDA #$FF        ; Space char
C36959:  STA $2180       ; Add to string
         INX             ; One more done
         CPX #$0008      ; Added 8?
         BNE C36959      ; Loop if not
         STZ $2180       ; End string
         RTS

; 42: Initialize Lineup's Status menu
C36966:  JSR C335F7      ; Reset/Stop stuff
         LDA $0200       ; Menu number
         STA $22         ; Memorize it
         STZ $0200       ; Actor arrows: Off...
         STZ $25         ; Never read...
         LDA #$40        ; Channel: 6
         TRB $43         ; Halt HDMA-6...
         JSR C36854      ; Set to shift text
         JSR C3699D      ; Draw menu; portrait
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$43        ; C3/6988
         STA $27         ; Queue: Sustain menu
         JMP C33609      ; BRT:1 + NMI

; 43: Sustain Lineup's Status menu
C36988:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3699C      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA $4C         ; Menu return cmd
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         LDA $22         ; Former menu
         STA $0200       ; Set as current
C3699C:  RTS

; Draw Lineup's Status menu, create portrait
C3699D:  JSR C36374      ; Draw windows
         JSR C36399      ; Draw blue text
         JSR C369C2      ; Get actor address
         JSR C36618      ; Draw actor info
         JSR C363D4      ; Upload tilemaps
         JSR C36823      ; Init portrait
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         LDA $28         ; Actor
         TAY             ; Index it
         JSR C369D7      ; Set portrait's X
         TDC             ; Clear A
         TAY             ; Portrait slot: 1
         JSR C36844      ; Set Y/ptr/timer
         PLB             ; Restore DB
         RTS

; Load actor number and address for Lineup's Status menu
C369C2:  TDC             ; Clear A
         LDA $C9         ; Actor
         STA $28         ; Memorize it
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor's address
         STA $67         ; Memorize it
         SEP #$20        ; 8-bit A
         TDC             ; ...
         LDA $C9         ; Actor
         RTS

; Set portrait's X position for Lineup's Status menu
C369D7:  LDA $1850,Y     ; Actor info
         BIT #$20        ; Back row?
         BEQ C369E5      ; Branch if not
         REP #$20        ; 16-bit A
         LDA #$001A      ; X: 26
         BRA C369EA      ; Skip 2 lines
C369E5:  REP #$20        ; 16-bit A
         LDA #$000E      ; X: 15
C369EA:  STA $33CA,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; 6A: Sustain shifted Status menu
C369F0:  JSR C36A52      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C36A23      ; Branch if not
         JSR C30F1D      ; Sound: Click
         STZ $0065       ; Edited slot HB
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9D8A,X   ; Chosen command
         STA $E0         ; Memorize it
         TDC             ; ...
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         REP #$20        ; 16-bit A
         TYA             ; Move it to A
         CLC             ; Prepare ADC
         ADC $64         ; Add edited slot
         TAY             ; Index sum
         SEP #$20        ; 8-bit A
         LDA $E0         ; Chosen command
         STA $0016,Y     ; Assign to actor
         JSR C36758      ; Redraw commands
         BRA C36A2C      ; Shift screen

; Fork: Handle B
C36A23:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C36A4B      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C36A2C:  LDA #$01        ; Blinker: Off
         TRB $46         ; Set menu flag
         LDA #$06        ; Frames: 6
         STA $20         ; Set scroll timer
         LDY #$FFF4      ; Speed: -12
         STY $9C         ; Set scroll speed
         LDA #$0C        ; C3/2255
         STA $27         ; Queue: Normal menu
         LDA #$65        ; C3/37AF
         STA $26         ; Next: Shift screen
         JSR C337C7      ; Load navig data
         LDA $5E         ; Old cursor row
         STA $4E         ; Set as current
         JSR C337D0      ; Relocate cursor
C36A4B:  RTS

; Load navigation data for shifted Status menu
C36A4C:  LDY #C36A5B     ; C3/6A5B
         JMP C30681      ; Load navig data

; Handle D-Pad for shifted Status menu
C36A52:  JSR C307B0      ; Handle D-Pad
C36A55:  LDY #C36A60     ; C3/6A60
         JMP C306C3      ; Relocate cursor

; Navigation data for shifted Status menu
C36A5B:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $10          ; 16 rows

; Cursor positions for shifted Status menu
C36A60:  dw $10F8        ; Empty			=== SNES: All are shifted leftward as command names are a letter longer
         dw $1CF8        ; Command 1
         dw $28F8        ; Command 2
         dw $34F8        ; Command 3
         dw $40F8        ; Command 4
         dw $4CF8        ; Command 5
         dw $58F8        ; Command 6
         dw $64F8        ; Command 7
         dw $70F8        ; Command 8
         dw $7CF8        ; Command 9
         dw $88F8        ; Command 10
         dw $94F8        ; Command 11
         dw $A0F8        ; Command 12
         dw $ACF8        ; Command 13
         dw $B8F8        ; Command 14
         dw $C4F8        ; Command 15 (unused)

; Text pointers for Status menu
C36A80:  dw C36AD9                              ; Vigor
         dw C36ADF                              ; Stamina
         dw C36AE7                              ; Mag.Pwr
         dw C36AEE                              ; Evade
         dw C36AF6                              ; MBlock‥
         dw C36B03                              ; ‥
         dw C36B07                              ; ‥
         dw C36B0B                              ; ‥
         dw C36B0F                              ; ‥
         dw C36B13                              ; ‥
         dw C36B17                              ; ‥



         dw C36AB2                              ; Status

; Text pointers for Status menu
C36A98:  dw C36ACA                              ; LV
         dw C36ACF                              ; HP
         dw C36AD4                              ; MP

; Text pointers for Status menu
C36A9E:  dw C36ABA                              ; /
         dw C36ABE                              ; /
         dw C36AC2                              ; %
         dw C36AC6                              ; %

; Text pointers for Status menu
C36AA6:  dw C36B1B                              ; Speed
         dw C36B22                              ; Bat.Pwr‥
         dw C36B2F                              ; Defense
         dw C36B36                              ; Mag.Def‥
         dw C36B43                              ; Your Exp:
         dw C36B50                              ; For level up:

; Positioned text for Status menu
C36AB2:  dw $78CD : db |ステータス[end]|		; Status
C36ABA:  dw $3A6B : db "/",$00
C36ABE:  dw $3AAB : db "/",$00
C36AC2:  dw $7F83 : db "%",$00
C36AC6:  dw $8883 : db "%",$00
C36ACA:  dw $3A1D : db "LV",$00
C36ACF:  dw $3A5D : db "HP",$00
C36AD4:  dw $3A9D : db "MP",$00
C36AD9:  dw $7ED1 : db |ちから[end]|		; Vigor			=== SNES: Shifted leftward (same below)
C36ADF:  dw $7FD1 : db |たいりょく[end]|		; Stamina
C36AE7:  dw $8851 : db |まりょく[end]|		; Mag.Pwr
C36AEE:  dw $7F69 : db |かいひりつ[end]|		; Evade			=== SNES: No "%"
C36AF6:  dw $8869 : db |まほうかいひりつ ‥[end]|	; MBlock‥		=== SNES: % instead of ..
C36B03:  dw $7EDD : db |‥[end]|
C36B07:  dw $7F5D : db |‥[end]|
C36B0B:  dw $7FDD : db |‥[end]|
C36B0F:  dw $885D : db |‥[end]|
C36B13:  dw $7EFB : db |‥[end]|
C36B17:  dw $7F7B : db |‥[end]|



C36B1B:  dw $7F11 : db |すばやさ[end]|		; Speed			=== SNES: +40h as no diacritics; shifted lefward (same below)
C36B22:  dw $7E29 : db |こうげきりょく  ‥[end]|		; Bat.Pwr‥		=== SNES: Leader is separate
C36B2F:  dw $7EA9 : db |ぼうぎょ[end]|		; Defense
C36B36:  dw $7FA9 : db |まほうぼうぎょ  ‥[end]|	; Mag.Def‥		=== SNES: Leader is separate
C36B43:  dw $7C11 : db |げんざいのけいけんち[end]|	; Your Exp:
C36B50:  dw $7D11 : db |つぎのレベルまで あと[end]|	; For level up:

; 5D: Initialize actor naming menu
C36B5E:  JSR C335F7      ; Reset/Stop stuff
         LDY $0201       ; Actor's address
         STY $67         ; Memorize it
         JSR C37076      ; Reset BGs' X/Y
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         STZ $4A         ; Page: 1st			=== SNES: Useless
         JSR C36D20      ; Load navig data
         JSR C36D29      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C36E29      ; Draw menu
         JSR C36D09      ; Set arrow's column
         LDA #$01        ; Min slot: 8			%%%
         LDY #C36FCA     ; C3/6FCA
         JSR C311DE      ; Queue large arrow
         JSR C36F63      ; Set to shift text
         JSR C36EB3      ; Get portrait colors
         JSR C36E98      ; Upload portrait GFX
         JSR C36DFC      ; Create portrait
         LDA #$02        ; Min slot: 16
         LDY #C3702C     ; C3/702C
         JSR C311DE      ; Queue small arrow
         LDA #$5F        ; C3/6BA5
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 5F: Sustain actor naming menu
C36BA5:  LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C36BB9      ; Branch if not
         LDA $4E         ; Cursor row			%%% Code to account for multiple pages
         CMP #$09        ; On bottom row?
         BNE C36BB9      ; Branch if not
         LDA #$60        ; C3/6C4A
         STA $26         ; Next: Scroll
         LDA #$15        ; Frames: 21
         STA $20         ; Set scroll timer

; Fork: Handle upward scrolling
C36BB9:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C36BCB      ; Branch if not
         LDA $4E         ; On top row?
         BNE C36BCB      ; Skip if not
         LDA #$61        ; C3/6C71
         STA $26         ; Next: Scroll
         LDA #$15        ; Frames: 21
         STA $20         ; Set scroll timer

; Fork: Handle L and R and intrapage navigation, redraw name
C36BCB:  JSR C30F54      ; Queue text upload
         JSR C36C99      ; Handle L and R
         JSR C36D26      ; Handle D-Pad
         JSR C36E86      ; Draw actor name

; Fork: Handle Start
C36BD7:  LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BEQ C36BE0      ; Branch if not
         JMP C36C24      ; Validate name

; Fork: Handle A
C36BE0:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C36BF7      ; Branch if not
         JSR C30F1D      ; Sound: Click
         TDC             ; Mode: Add
         JSR C36CD0      ; Add letter
         LDA $28         ; Arrow's column
         CMP #$05        ; Rightmost?
         BEQ C36BF4      ; Exit if so
         INC A           ; Go right by 1
C36BF4:  STA $28         ; Save changes
         RTS

; Fork: Handle B
C36BF7:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C36C23      ; Exit if not
         JSR C30F32      ; Sound: Delete
         LDA $28         ; Arrow's column
         BEQ C36C23      ; Exit if first
         CMP #$05        ; Rightmost?
         BNE C36C17      ; Branch if not
         JSR C36CF7      ; Define Y
         LDA $0002,Y     ; Letter 6
         CMP #$FF        ; Blank?
         BEQ C36C17      ; Branch if so
         LDA #$FF        ; Mode: Delete V1
         JMP C36CD0      ; Delete letter 6

; Fork: Delete non-sixth letter
C36C17:  LDA #$01        ; Mode: Delete V2
         JSR C36CD0      ; Delete letter
         LDA $28         ; Arrow's column
         BEQ C36C21      ; ...
         DEC A           ; Go left by 1
C36C21:  STA $28         ; Save changes
C36C23:  RTS

; Validate entered actor name
C36C24:  LDY $67         ; Actor's address
         LDX $00         ; Letter count: 0
C36C28:  LDA $0002,Y     ; Letter
         CMP #$FF        ; Terminator?
         BNE C36C3D      ; Valid if not
         INY             ; Letter index +1
         INX             ; Letter count +1
         CPX #$0006      ; Done 6 letters?
         BNE C36C28      ; Loop if not
         JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS             ; Exit
C36C3D:  JSR C30F1D      ; Sound: Click
         STZ $0205       ; Never read...
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS

; 60: Scroll to actor naming page 2 if valid starting point		%%%
C36C4A:  LDA $20         ; Timer expired?
         BEQ C36C66      ; Finalize if so
         LDA $4A         ; Bottom of P2?
         BNE C36C6C      ; Cancel if so
         REP #$21        ; 16-bit A; C-
         LDA $7E9BCD     ; BG1 V-Shift
         ADC #$0008      ; Go 8 px down
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
         RTS

; Fork: Restore control
C36C66:  LDA #$64        ; Chars per page
         STA $4A         ; Set tbl index
         STZ $4E         ; Cursor row: 1
C36C6C:  LDA #$5F        ; C3/656C
         STA $26         ; Next: Resume
         RTS

; 61: Scroll to actor naming page 1 if valid starting point		%%%
C36C71:  LDA $20         ; Timer expired?
         BEQ C36C8E      ; Finalize if so
         LDA $4A         ; Top of page 1?
         BEQ C36C94      ; Cancel if so
         REP #$20        ; 16-bit A
         LDA $7E9BCD     ; BG1 V-Shift
         SEC             ; Prepare SBC
         SBC #$0008      ; Go 8 px up
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
         RTS

; Fork: Restore control
C36C8E:  STZ $4A         ; Char tbl index
         LDA #$09        ; Row: Last
         STA $4E         ; Set cursor's
C36C94:  LDA #$5F        ; C3/656C
         STA $26         ; Next: Resume
         RTS

; Handle L and R for actor naming menu			%%%
C36C99:  LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BNE C36CA3      ; Branch if so
         BIT #$20        ; Pushing L?
         BEQ C36CBD      ; Exit if not
C36CA3:  JSR C30F0E      ; Sound: Cursor
         LDA $4A         ; On page 2?
         BNE C36CBE      ; Branch if so

; Fork: Switch to page 2
C36CAA:  LDA #$64        ; Chars per page
         STA $4A         ; Set tbl index
         REP #$20        ; 16-bit A
         LDA #$0070      ; BG1 V-Shift: 112
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
C36CBD:  RTS

; Fork: Switch to page 1
C36CBE:  STZ $4A         ; Char tbl index
         REP #$20        ; 16-bit A
         LDA #$FFD0      ; BG1 V-Shift: -48
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
         RTS

; Add or remove letter from actor name
C36CD0:  PHA             ; Save mode
         JSR C36CF7      ; Define Y
         PLA             ; Deleting 6th?
         BMI C36CE2      ; Branch if so
         BEQ C36CE8      ; Branch if adding
         LDA #$FF        ; Char: Terminator
         STA $0002,Y     ; ...
         STA $0001,Y     ; Clear last letter
         RTS

; Fork: Delete letter 6
C36CE2:  LDA #$FF        ; Char: Terminator
         STA $0002,Y     ; Clear letter 6
         RTS

; Fork: Add selected letter
C36CE8:  TDC             ; Clear A
         LDA $4B         ; Selected slot
         CLC             ; Prepare ADC
         ADC $4A         ; +100 if page 2		=== SNES: Always +0 (only one page)
         TAX             ; Index sum
         LDA $D8E8C8,X   ; Chosen letter
         STA $0002,Y     ; Add to name
         RTS

; Get index for overwritten letter in actor naming menu
C36CF7:  LDY $67         ; Actor's address
         LDA $28         ; Arrow column
         STA $E7         ; Memorize it
         STZ $E8         ; Clear HB
         REP #$20        ; 16-bit A
         TYA             ; Actor's address
         CLC             ; Prepare ADC
         ADC $E7         ; Add column
         TAY             ; Put sum in Y
         SEP #$20        ; 8-bit A
         RTS

; Initialize arrow's column for actor naming menu
C36D09:  LDY $67         ; Actor's address
         LDX $00         ; Column: 1st
C36D0D:  LDA $0002,Y     ; Current letter
         CMP #$FF        ; Terminator?
         BEQ C36D1C      ; Branch if so
         INY             ; Point to next
         INX             ; Arrow column +1
         CPX #$0006      ; Done 6 letters?
         BNE C36D0D      ; Loop if not
         DEX             ; Column: 6th
C36D1C:  TXA             ; Move column to A
         STA $28         ; Set arrow column
         RTS

; Load navigation data for actor naming menu
C36D20:  LDY #C36D2F     ; C3/6D2F
         JMP C30681      ; Load navig data

; Handle D-Pad for actor naming menu
C36D26:  JSR C307B0      ; Handle D-Pad
C36D29:  LDY #C36D34     ; C3/6D34
         JMP C306C3      ; Relocate cursor

; Navigation data for actor naming menu
C36D2F:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $0A          ; 10 columns
         db $0A          ; 10 rows			=== SNES: 7

; Cursor positions for actor naming menu		%%% SNES: Fewer letters
C36D34:  dw $3838        ; Row 1, column 1		=== SNES: Positions differ
         dw $3848        ; Row 1, column 2
         dw $3858        ; Row 1, column 3
         dw $3868        ; Row 1, column 4
         dw $3878        ; Row 1, column 5
         dw $3890        ; Row 1, column 6
         dw $38A0        ; Row 1, column 7
         dw $38B0        ; Row 1, column 8
         dw $38C0        ; Row 1, column 9
         dw $38D0        ; Row 1, column 10
         dw $4838        ; Row 2, column 1
         dw $4848        ; Row 2, column 2
         dw $4858        ; Row 2, column 3
         dw $4868        ; Row 2, column 4
         dw $4878        ; Row 2, column 5
         dw $4890        ; Row 2, column 6
         dw $48A0        ; Row 2, column 7
         dw $48B0        ; Row 2, column 8
         dw $48C0        ; Row 2, column 9
         dw $48D0        ; Row 2, column 10
         dw $5838        ; Row 3, column 1
         dw $5848        ; Row 3, column 2
         dw $5858        ; Row 3, column 3
         dw $5868        ; Row 3, column 4
         dw $5878        ; Row 3, column 5
         dw $5890        ; Row 3, column 6
         dw $58A0        ; Row 3, column 7
         dw $58B0        ; Row 3, column 8
         dw $58C0        ; Row 3, column 9
         dw $58D0        ; Row 3, column 10
         dw $6838        ; Row 4, column 1
         dw $6848        ; Row 4, column 2
         dw $6858        ; Row 4, column 3
         dw $6868        ; Row 4, column 4
         dw $6878        ; Row 4, column 5
         dw $6890        ; Row 4, column 6
         dw $68A0        ; Row 4, column 7
         dw $68B0        ; Row 4, column 8
         dw $68C0        ; Row 4, column 9
         dw $68D0        ; Row 4, column 10
         dw $7838        ; Row 5, column 1
         dw $7848        ; Row 5, column 2
         dw $7858        ; Row 5, column 3
         dw $7868        ; Row 5, column 4
         dw $7878        ; Row 5, column 5
         dw $7890        ; Row 5, column 6
         dw $78A0        ; Row 5, column 7
         dw $78B0        ; Row 5, column 8
         dw $78C0        ; Row 5, column 9
         dw $78D0        ; Row 5, column 10
         dw $8838        ; Row 6, column 1
         dw $8848        ; Row 6, column 2
         dw $8858        ; Row 6, column 3
         dw $8868        ; Row 6, column 4
         dw $8878        ; Row 6, column 5
         dw $8890        ; Row 6, column 6
         dw $88A0        ; Row 6, column 7
         dw $88B0        ; Row 6, column 8
         dw $88C0        ; Row 6, column 9
         dw $88D0        ; Row 6, column 10
         dw $9838        ; Row 7, column 1
         dw $9848        ; Row 7, column 2
         dw $9858        ; Row 7, column 3
         dw $9868        ; Row 7, column 4
         dw $9878        ; Row 7, column 5
         dw $9890        ; Row 7, column 6
         dw $98A0        ; Row 7, column 7
         dw $98B0        ; Row 7, column 8
         dw $98C0        ; Row 7, column 9
         dw $98D0        ; Row 7, column 10
         dw $A838        ; Row 8, column 1
         dw $A848        ; Row 8, column 2
         dw $A858        ; Row 8, column 3
         dw $A868        ; Row 8, column 4
         dw $A878        ; Row 8, column 5
         dw $A890        ; Row 8, column 6
         dw $A8A0        ; Row 8, column 7
         dw $A8B0        ; Row 8, column 8
         dw $A8C0        ; Row 8, column 9
         dw $A8D0        ; Row 8, column 10
         dw $B838        ; Row 9, column 1
         dw $B848        ; Row 9, column 2
         dw $B858        ; Row 9, column 3
         dw $B868        ; Row 9, column 4
         dw $B878        ; Row 9, column 5
         dw $B890        ; Row 9, column 6
         dw $B8A0        ; Row 9, column 7
         dw $B8B0        ; Row 9, column 8
         dw $B8C0        ; Row 9, column 9
         dw $B8D0        ; Row 9, column 10
         dw $C838        ; Row 10, column 1
         dw $C848        ; Row 10, column 2
         dw $C858        ; Row 10, column 3
         dw $C868        ; Row 10, column 4
         dw $C878        ; Row 10, column 5
         dw $C890        ; Row 10, column 6
         dw $C8A0        ; Row 10, column 7
         dw $C8B0        ; Row 10, column 8
         dw $C8C0        ; Row 10, column 9
         dw $C8D0        ; Row 10, column 10

; Create portrait for actor naming menu
C36DFC:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA #C30BF7     ; Anim table ptr
         STA $32C9,X     ; Set sprite's
         LDA #$0010      ; X: 16
         STA $33CA,X     ; Set sprite's
         LDA #$0010      ; Y: 16
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         PLB             ; Restore DB
         RTS

; Draw actor naming menu
C36E29:  JSR C371BC      ; Clear BG2 map A
         LDY #C36E8C     ; C3/6E8C
         JSR C303C4      ; Draw name window		=== SNES: Different drawing order
         LDY #C36E90     ; C3/6E90
         JSR C303C4      ; Draw font window


         LDY #C36E94     ; C3/6E94
         JSR C303C4      ; Draw face window
         JSR C30EBD      ; Upload windows
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C371B2      ; Clear BG1 map C
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #$385B      ; Tilemap ptr			=== SNES position differs
         LDY #$E8C8      ; D8/E8C8
         STY $E7         ; Set src LBs
         LDA #$D8        ; Bank: D8
         STA $E9         ; Set src HB
         LDA #$10        ; Text rows: 16		=== SNES: 7
         STA $E5         ; Set for options
         JSR C36EE6      ; Draw BG1a options		=== SNES: Only one case
         LDX #$485B      ; Tilemap ptr			%%% SNES: No BG1c options
         LDY #$E968      ; D8/E968
         STY $E7         ; Set src LBs
         LDA #$D8        ; Bank: D8
         STA $E9         ; Set src HB
         LDA #$04        ; Text rows: 4
         STA $E5         ; Set for options
         JSR C36EE6      ; Draw BG1c options
         JSR C36E86      ; Draw actor name
         JSR C30E93      ; Upload BG1 A+B
         JSR C30EA1      ; Upload BG1 B+C
         JSR C30EAF      ; Upload BG1 C+D
         JSR C371D0      ; Clear BG3 map A
         JMP C30ED9      ; Upload BG3 A+B

; Draw actor name for actor naming menu
C36E86:  LDY #$40E9      ; Text position		=== SNES position differs
         JMP C3356A      ; Draw actor name

; Window layout for actor naming menu
C36E8C:  dw $589B,$0212  ; 20x04 at $589B (Name)	=== SNES: Shifted down for "Please..." message
C36E90:  dw $5997,$1416  ; 24x22 at $5997 (Options)	=== SNES: 24x19 and shifted down too
C36E94:  dw $588B,$0505  ; 07x07 at $588B (Portrait)


; Upload portrait for actor naming menu
C36E98:  LDY $67         ; Actor's address
         TDC             ; Clear A
         LDA $0001,Y     ; Graphics set
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA #$2600      ; $2600
         STA $2116       ; Set VRAM ptr
         LDA.L C376AF,X  ; GFX pointer
         TAX             ; Index it
         JSR C37794      ; Load portrait
         SEP #$20        ; 8-bit A
         RTS

; Load portrait colors for actor naming menu
C36EB3:  LDA #$10        ; Colors: 16
         STA $E3         ; Set counter
         LDY $67         ; Actor's address
         TDC             ; Clear A
         LDA $0001,Y     ; Graphics set
         TAX             ; Index it
         LDA.L C37694,X  ; Palette number
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         TAX             ; Index it
         LDY $00         ; RAM index: 0
C36ECC:  REP #$20        ; 16-bit A
         PHX             ; Save ROM index
         LDA $ED5860,X   ; Portrait color
         TYX             ; RAM index
         STA $7E3149,X   ; To OBJ pal 0
         SEP #$20        ; 8-bit A
         PLX             ; ROM index
         INX             ; ROM index +1
         INX             ; ROM index +1
         INY             ; RAM index +1
         INY             ; RAM index +1
         DEC $E3         ; One less color
         BNE C36ECC      ; Loop till last
         SEP #$20        ; 8-bit A
         RTS

; Draw options in actor naming menu
C36EE6:  STX $EB         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
         LDY $00         ; ROM index: 0
C36EEE:  LDA #$0A        ; Columns: 10
         STA $E6         ; Set counter
         LDX $00         ; RAM index: 0
C36EF4:  LDA [$E7],Y     ; Character
         STA $E0         ; Memorize it
         PHY             ; Save ROM index

; Fork: Character without diacritic
C36EF9:  CMP #$53        ; Normal char?
         BCC C36F03      ; Branch if not
         LDA #$FF        ; Space char
         STA $E1         ; Set diacritic
         BRA C36F23      ; Update tilemap

; Fork: Character with handakuten
C36F03:  CMP #$49        ; Bogus char?
         BCC C36F14      ; Branch if not
         LDA #$52        ; Mark: [°]
         STA $E1         ; Set diacritic
         LDA $E0         ; Letter number
         CLC             ; Prepare ADC
         ADC #$17        ; Get true one
         STA $E0         ; Save changes
         BRA C36F23      ; Update tilemap

; Fork: Character with dakuten
C36F14:  CMP #$20        ; Roman range?
         BCC C36F23      ; Branch if not
         LDA #$51        ; Mark: ["]
         STA $E1         ; Set diacritic
         LDA $E0         ; Letter number
         CLC             ; Prepare ADC
         ADC #$40        ; Get true one
         STA $E0         ; Save changes

; Fork: Add character to tilemap
C36F23:  TXY             ; Base RAM index
         LDA $E1         ; Diacritic
         STA [$EB],Y     ; Add to tilemap
         INY             ; Index +1
         LDA $29         ; Palette, etc.
         STA [$EB],Y     ; Set attributes
         REP #$20        ; 16-bit A
         TXA             ; Base RAM index
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         LDA $E0         ; Base character
         STA [$EB],Y     ; Add to tilemap
         INY             ; Index +1
         LDA $29         ; Palette, etc.
         STA [$EB],Y     ; Set attributes
         INX             ; RAM index +1
         INX             ; RAM index +1
         INX             ; RAM index +1
         INX             ; RAM index +1
         PLY             ; ROM index
         INY             ; ROM index +1
         LDA $E6         ; Columns left
         CMP #$06        ; At separator?
         BNE C36F4E      ; Branch if not
         INX             ; RAM index +1
         INX             ; RAM index +1
C36F4E:  DEC $E6         ; One less column
         BNE C36EF4      ; Loop till last
         REP #$20        ; 16-bit A
         LDA $EB         ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$0080      ; +2 rows down
         STA $EB         ; Save changes
         SEP #$20        ; 8-bit A
         DEC $E5         ; One less row
         BNE C36EEE      ; Loop till last
         RTS

; Set to condense text in actor naming menu
C36F63:  LDX $00         ; Index: 0
C36F65:  LDA.L C36FBD,X  ; BG1 V-Pan data
         STA $7E9BC9,X   ; Save in RAM
         INX             ; Index +1
         CPX #$000D      ; End of table?
         BNE C36F65      ; Loop if not
         LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set CH5 mode
         LDA #$0E        ; $210E
         STA $4351       ; To BG1 V-Scroll
         LDY #$9BC9      ; 7E/9BC9
         STY $4352       ; Set CH5 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4354       ; Set CH5 src HB
         LDA #$7E        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         LDA #$02        ; 1Rx2B to PPU
         STA $4360       ; Set CH6 mode
         LDA #$0D        ; $210D
         STA $4361       ; To BG1 H-Scroll
         LDY #C36FB0     ; C3/6FB0
         STY $4362       ; Set CH6 src LBs
         LDA #$C3        ; Bank: C3
         STA $4364       ; Set CH6 src HB
         LDA #$C3        ; ...
         STA $4367       ; Set indir HB
         LDA #$40        ; Channel: 6
         TSB $43         ; Queue HDMA-6
         RTS

; BG1 H-Shift table for the above (merges tilemaps)
C36FB0:  db $2F,$00,$01  ; Actor name			=== SNES: More lines
         db $50,$00,$00  ; Upper chars
         db $50,$00,$00  ; Lower chars
         db $10,$00,$01  ; Blank area
         db $00          ; End

; BG1 V-Shift table for the above (condenses text)
C36FBD:  db $2F,$00,$00  ; Actor name			=== SNES: More lines
         db $50,$D0,$FF  ; Upper chars
         db $50,$D0,$FF  ; Lower chars
         db $10,$00,$00  ; Blank area
         db $00          ; End

; Update large arrow in actor naming menu		%%%
C36FCA:  TAX             ; Index mode
         JMP (C36FCE,X)  ; Handle mode

; Jump table for the above
C36FCE:  dw C36FD2       ; Initialize arrow
         dw C36FF5       ; Sustain arrow

; Mode 0: Initialize arrow
C36FD2:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #C37015     ; Anim table ptr
         STA $32C9,X     ; Set arrow's
         LDA #$0090      ; X: 144
         STA $33CA,X     ; Set arrow's
         LDA #$0028      ; Base Y: 40
         STA $344A,X     ; Set arrow's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer

; Mode 1: Sustain arrow
C36FF5:  LDY $2D         ; Queue index
         LDA $4A         ; On first page?
         BEQ C36FFF      ; Branch if so
         LDA #$02        ; Arrow: Up
         BRA C37000      ; Skip a line
C36FFF:  TDC             ; Arrow: Down
C37000:  TAX             ; Set index
         REP #$20        ; 16-bit A
         LDA.L C37011,X  ; Anim table ptr
         STA $32C9,Y     ; Set arrow's
         SEP #$20        ; 8-bit A
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Pointers for actor naming menu's large arrows
C37011:  dw C37015       ; Downward arrow
         dw C3701E       ; Upward arrow

; Animation table for large downward arrow in actor naming menu
C37015:  dw C3C3B5       ; Hide arrow
         db $10          ; Frames: 16
         dw C37027       ; Show arrow
         db $10          ; Frames: 16
         dw C3C3B5       ; Bogus...
         db $FF          ; Loop

; Animation table for large upward arrow in actor naming menu
C3701E:  dw C3C3B5       ; Hide arrow
         db $10          ; Frames: 16
         dw C3C3BB       ; Show arrow
         db $10          ; Frames: 16
         dw C3C3B5       ; Bogus...
         db $FF          ; Loop

; OAM for large downward arrow in actor naming menu
C37027:  db $01          ; Tiles: 1
         dw $A080        ; 16x16, X+0, Y+160
         dw $3E03        ; Tile 3, pal 7, prio 3

; Update small arrow in actor naming menu
C3702C:  TAX             ; Index mode
         JMP (C37030,X)  ; Handle mode

; Jump table for the above
C37030:  dw C37034       ; Initialize arrow
         dw C37054       ; Sustain arrow

; Mode 0: Initialize arrow
C37034:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #C3C34E     ; Anim table ptr
         STA $32C9,X     ; Set sprite's
         LDA #$0020      ; Y: 32			=== SNES: 64 (windows are shifted down for new window at the top)
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         STZ $33CB,X     ; No use...
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         INC $3649,X     ; Mode +1

; Mode 1: Sustain arrow
C37054:  LDY $2D         ; Queue index
         TDC             ; Clear A
         LDA $28         ; Arrow's slot
         TAX             ; Index it
         LDA.L C37066,X  ; X position
         STA $33CA,Y     ; Set sprite's
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Arrow's X positions in actor naming menu
C37066:  db $78          ; Letter 1
         db $80          ; Letter 2
         db $88          ; Letter 3
         db $90          ; Letter 4
         db $98          ; Letter 5
         db $A0          ; Letter 6




; Reset menu or ending variables
C3706C:  JSL $D4CDF3     ; Reset many vars
         JSR C37076      ; Reset BGs' X/Y
         JMP C3B0D9      ; Clear VWF GFX

; Reset BG positions
C37076:  LDY $00         ; Clear Y
         STY $35         ; BG1 X-Loc: 0
         STY $39         ; BG2 X-Loc: 0
         STY $3D         ; BG3 X-Loc: 0
         STY $37         ; BG1 Y-Loc: 0
         STY $3B         ; BG2 Y-Loc: 0
         STY $3F         ; BG3 Y-Loc: 0
         STY $41         ; List V-Spd: 0
         RTS

; Get party info from SRAM block
C37087:  JSL $D4CA00     ; Clear all info
         TDC             ; Clear A
         TAX             ; 1st: Terra
         TXY             ; ...
C3708E:  LDA $1850,X     ; Party info
         AND #$40        ; Object's off?
         BEQ C370B3      ; Skip if so
         LDA $1850,X     ; Party info
         AND #$07        ; Get party
         CMP $1A6D       ; Active party?
         BNE C370B3      ; Skip if not
         LDA $1850,X     ; Party info
         PHA             ; Memorize it
         AND #$18        ; Roster slot
         STA $E0         ; ...
         LSR A           ; Put in b2-b3
         LSR A           ; Put in b1-b2
         LSR A           ; Now 0-3
         TAY             ; Index it
         PLA             ; Party info
         STA $0075,Y     ; Set member's
         TXA             ; Actor slot
         STA $0069,Y     ; Set member's
C370B3:  INX             ; Actor slot +1
         CPX #$0010      ; Done 16 chars?
         BNE C3708E      ; Loop if not
         LDY $00         ; 1st: Member 1
C370BB:  TDC             ; Clear A
         LDA $0069,Y     ; Actor
         CMP #$FF        ; Empty slot?
         BEQ C370D4      ; Skip if so
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor's address
         PHA             ; Memorize it
         TYA             ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         PLA             ; SRAM address
         STA $6D,X       ; Set member's
         SEP #$20        ; 8-bit A
C370D4:  INY             ; Member slot +1
         CPY #$0004      ; Done 4 slots?
         BNE C370BB      ; Loop if not
         RTS

; SRAM block addresses for actor data
C370DB:  dw $1600        ; 00: Terra
         dw $1625        ; 01: Locke
         dw $164A        ; 02: Cyan
         dw $166F        ; 03: Shadow
         dw $1694        ; 04: Edgar
         dw $16B9        ; 05: Sabin
         dw $16DE        ; 06: Celes
         dw $1703        ; 07: Strago
         dw $1728        ; 08: Relm
         dw $174D        ; 09: Setzer
         dw $1772        ; 0A: Mog
         dw $1797        ; 0B: Gau
         dw $17BC        ; 0C: Gogo
         dw $17E1        ; 0D: Umaro
         dw $1806        ; 0E: Guest 1
         dw $182B        ; 0F: Guest 2

; Copy party info to SRAM block
C370FB:  TDC             ; Clear A
         TAX             ; 1st: Member 1
         TAY             ; ...
C370FE:  LDA $69,X       ; Actor in slot
         BMI C37114      ; Skip if nobody
         TAY             ; Index it
         LDA $75,X       ; Party info
         AND #$E7        ; Clear roster slot
         STA $E0         ; Memorize info
         TDC             ; ...
         TXA             ; Member slot
         ASL A           ; Put in b1-b2
         ASL A           ; Put in b2-b3
         ASL A           ; Put in b3-b4
         CLC             ; ...
         ADC $E0         ; Add saved info
         STA $1850,Y     ; Put in SRAM area
C37114:  INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C370FE      ; Loop if not
         RTS

; Memorize current party (useless)
C3711B:  REP #$20        ; 16-bit A
         LDA $69         ; Members 1 and 2
         STA $7EAA89     ; Memorize them
         LDA $6B         ; Members 3 and 4
         STA $7EAA8B     ; Memorize them
         SEP #$20        ; 8-bit A
         RTS

; Draw multiple strings without diacritics		=== SNES: Single text function, not two
C3712C:  STX $F1         ; Set ptrs loc
         STY $EF         ; Set counter
         LDA #$C3        ; Bank: C3
         STA $F3         ; Set loc HB
         LDY $00         ; Index: 0
C37136:  REP #$20        ; 16-bit A
         LDA [$F1],Y     ; Text pointer
         STA $E7         ; Set src LBs
         PHY             ; Save index
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw string
         PLY             ; String index
         INY             ; Index +1
         INY             ; Index +1
         CPY $EF         ; None left?
         BNE C37136      ; Loop if not
         RTS

; Draw multiple strings with diacritics but without Roman characters		%%%
C3714E:  STX $F1         ; Set ptrs loc
         STY $EF         ; Set counter
         LDA #$C3        ; Bank: C3
         STA $F3         ; Set loc HB
         LDY $00         ; Index: 0
C37158:  REP #$20        ; 16-bit A
         LDA [$F1],Y     ; Text pointer
         STA $E7         ; Set src LBs
         PHY             ; Save index
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         JSR C3032C      ; Draw string
         PLY             ; String index
         INY             ; Index +1
         INY             ; Index +1
         CPY $EF         ; None left?
         BNE C37158      ; Loop if not
         RTS

; Set Window 1 positions per scanline
C37170:  LDA #$01        ; 2Rx1B to PPU
         STA $4320       ; Set CH2 mode
         LDA #$26        ; $2126, $2127
         STA $4321       ; To Win 1 L+R
         LDY #C3718F     ; C3/718F
         STY $4322       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4324       ; Set src HB
         LDA #$C3        ; ...
         STA $4327       ; Set indir HB
         LDA #$04        ; Channel: 2
         TSB $43         ; Queue HDMA-2
         RTS

; Window 1 positions per scanline
C3718F:  db $07,$FF,$00  ; No range
         db $78,$08,$F7  ; 8, 247
         db $58,$08,$F7  ; 8, 247
         db $08,$FF,$00  ; No range
         db $00          ; End

; Set global Window 1 positions
C3719C:  LDA #$04        ; Channel: 2
         TRB $43         ; Halt Win1 HDMA
         STZ $2126       ; Win1-L: 0
         LDA #$FF        ; Win1-R: 255
         STA $2127       ; Set register
         RTS

; Clear BG1 tilemap A
C371A9:  LDX $00         ; 7E/3849
         BRA C371E2      ; Clear map

; Clear BG1 tilemap B
C371AD:  LDX #$0800      ; 7E/4049
         BRA C371E2      ; Clear map

; Clear BG1 tilemap C
C371B2:  LDX #$1000      ; 7E/4849
         BRA C371E2      ; Clear map

; Clear BG1 tilemap D
C371B7:  LDX #$1800      ; 7E/5049
         BRA C371E2      ; Clear map

; Clear BG2 tilemap A
C371BC:  LDX #$2000      ; 7E/5849
         BRA C371E2      ; Clear map

; Clear BG2 tilemap B
C371C1:  LDX #$2800      ; 7E/6049
         BRA C371E2      ; Clear map

; Clear BG2 tilemap C
C371C6:  LDX #$3000      ; 7E/6849
         BRA C371E2      ; Clear map

; Clear BG2 tilemap D (unused)
C371CB:  LDX #$3800      ; 7E/7049
         BRA C371E2      ; Clear map

; Clear BG3 tilemap A
C371D0:  LDX #$4000      ; 7E/7849
         BRA C371E2      ; Clear map

; Clear BG3 tilemap B
C371D5:  LDX #$4800      ; 7E/8049
         BRA C371E2      ; Clear map

; Clear BG3 tilemap C
C371DA:  LDX #$5000      ; 7E/8849
         BRA C371E2      ; Clear map

; Clear BG3 tilemap D
C371DF:  LDX #$5800      ; 7E/9049
C371E2:  REP #$20        ; 16-bit A
         TDC             ; Clear A
         LDY #$0200      ; Tiles: 1024
C371E8:  STA $7E3849,X   ; Clear tile
         INX             ; Index +1
         INX             ; Index +1
         STA $7E3849,X   ; Clear tile
         INX             ; Index +1
         INX             ; Index +1
         DEY             ; 2 less tiles
         BNE C371E8      ; Loop till 0
         SEP #$20        ; 8-bit A
         RTS

; Load graphics, colors, enemy, and prize for Colosseum matchup
C371FA:  JSR C377A4      ; ...
         JSR C372A7      ; BG3 font GFX
         JSR C3737C      ; Font colors
         JSR C3739D      ; ...
         JSR C375FB      ; Cursor/VS GFX
         JSR C3745B      ; Actor colors
         JSR C37418      ; Cursor/VS colors
         JSR C37616      ; ...
         JSR C3747D      ; Actor sprites
         JSR C3B8B3      ; Prize/enemy data
         JMP C3BCB8      ; Arena

; Load non-skin graphics and colors for menu
C3721B:  TDC             ; Clear A
         LDA $0200       ; Menu
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C37224,X)  ; Load data

; Jump table for the above
C37224:  dw C3727D       ; Main menu
         dw C37298       ; Actor naming
         dw C3727D       ; Load menu
         dw C37262       ; Shop
         dw C37244       ; Lineup
         dw C37244       ; Bogus...
         dw C37238       ; SwdTech naming
         dw C3727D       ; Colosseum
         dw C37244       ; Final battle lineup
         dw C37244       ; Bogus...

; Load graphics and colors for SwdTech naming menu
C37238:  JSR C372CB      ; BG1 font GFX
         JSR C3737C      ; Font colors
         JSR C375FB      ; Cursor/arrow GFX
         JMP C37418      ; Their colors

; Load graphics and colors for Lineup or final battle menu
C37244:  JSR C377A4      ; Blank portrait
         JSR C372A7      ; BG3 font GFX
         JSR C372CB      ; BG1 font GFX
         JSR C3737C      ; Font colors
         JSR C3739D      ; Portrait colors...
         JSR C375FB      ; Cursor/icon GFX
         JSR C3745B      ; Actor colors
         JSR C37418      ; Cursor/icon pals
         JSR C37616      ; Portrait GFX...
         JMP C3747D      ; Actor sprites

; Load graphics and colors for shop menu
C37262:  JSR C372A7      ; BG3 font GFX
         JSR C372CB      ; BG1 font GFX
         JSR C3737C      ; Font colors
         JSR C3739D      ; Portrait colors...
         JSR C375FB      ; Cursor/icon GFX
         JSR C3745B      ; Actor colors
         JSR C37418      ; Cursor/icon pals
         JSR C37616      ; Portrait GFX...
         JMP C3750D      ; Actor sprites

; Load graphics and colors for Load, Main, or Colosseum menu
C3727D:  JSR C372A7      ; BG3 font GFX
         JSR C372CB      ; BG1 font GFX
         JSR C3737C      ; Font colors
         JSR C375FB      ; Cursor/icon GFX
         JSR C37616      ; Portrait GFX
         JSR C3739D      ; Portrait colors
         JSR C3747D      ; Actor sprites
         JSR C37418      ; Cursor/icon pals
         JMP C373F4      ; Grayscale pal

; Load graphics and colors for actor naming menu
C37298:  JSR C372A7      ; Blank BG tile
         JSR C372CB      ; BG1 font GFX
         JSR C3737C      ; Font colors
         JSR C375FB      ; Cursor GFX
         JMP C37418      ; Cursor colors

; Upload BG3 font graphics and erase VWF description
C372A7:  REP #$20        ; 16-bit A
         LDY #$6000      ; $6000
         STY $2116       ; Set VRAM ptr
         LDX $00         ; Index: 0
C372B1:  LDA $C47FC0,X   ; Font graphics
         STA $2118       ; Save in VRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$1000      ; 256th tile?
         BNE C372B1      ; Loop if not
C372BF:  STA $2118       ; Clear desc GFX
         INX             ; Index +1
         CPX #$1400      ; 128th tile?
         BNE C372BF      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Upload BG1 font graphics
C372CB:  LDY #$5000      ; $5000
         STY $2116       ; Set VRAM ptr
         REP #$20        ; 16-bit A
         TDC             ; Clear A
         TAX             ; Index: 0
C372D5:  LDY #$0008      ; 8-px rows: 8
C372D8:  LDA.L C37330,X  ; Square GFX
         STA $2118       ; Save in VRAM
         DEY             ; One less row
         BNE C372D8      ; Loop till last
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 8 tiles?
         BNE C372D5      ; Loop if not
         LDX $00         ; Index: 0
C372EB:  LDY #$0008      ; 8-px rows: 8
C372EE:  LDA $C48040,X   ; Font GFX row
         STA $2118       ; Save in VRAM
         INX             ; Index +1
         INX             ; Index +1
         DEY             ; One less row
         BNE C372EE      ; Loop till last
         STZ $2118       ; Planes 1C, 1D
         STZ $2118       ; Planes 2C, 2D
         STZ $2118       ; Planes 3C, 3D
         STZ $2118       ; Planes 4C, 4D
         STZ $2118       ; Planes 5C, 5D
         STZ $2118       ; Planes 6C, 6D
         STZ $2118       ; Planes 7C, 7D
         STZ $2118       ; Planes 8C, 8D
         CPX #$0F80      ; 248th tile?
         BNE C372EB      ; Loop if not
         LDY #$7800      ; $7800
         STY $2116       ; Set VRAM ptr
         LDX $00         ; Index: 0
C3731F:  LDA $ED0000,X   ; Skin GFX...
         STA $2118       ; Save in VRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$1000      ; Done 8 skins?
         BNE C3731F      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Square BG1 tiles, encoded as a single row
C37330:  dw $0000,$0000  ; Blank tile
         dw $00FF,$0000  ; Config: Palette color 1
         dw $FF00,$0000  ; Config: Palette color 2
         dw $FFFF,$0000  ; Config: Palette color 3
         dw $0000,$00FF  ; Config: Palette color 4
         dw $00FF,$00FF  ; Config: Palette color 5
         dw $FF00,$00FF  ; Config: Palette color 6
         dw $FFFF,$00FF  ; Config: Palette color 7

; Reset all skin colors
C37350:  LDX #$0008      ; Skins left: 8
         STX $E7         ; Set counter
         LDX #$0000      ; ROM index: 0
         TXY             ; RAM index: 0
         REP #$20        ; 16-bit A
C3735B:  LDA #$0007      ; Colors left: 7
         STA $E9         ; Set counter
C37360:  LDA $ED1C02,X   ; Default color
         STA $1D57,Y     ; Save in options
         INX             ; ROM index +1
         INX             ; ROM index +1
         INY             ; RAM index +1
         INY             ; RAM index +1
         DEC $E9         ; One less color
         BNE C37360      ; Loop till last
         TXA             ; ROM index
         CLC             ; Prepare ADC
         ADC #$0012      ; Reach next skin
         TAX             ; Reindex it
         DEC $E7         ; One less skin
         BNE C3735B      ; Loop till last
         SEP #$20        ; 8-bit A
         RTS

; Load font and black background's colors
C3737C:  LDX $00         ; Color index: 0
         TXA             ; CGRAM: $0000
         STA $2121       ; To BG color 0
C37382:  REP #$20        ; 16-bit A
         LDA $D8E800,X   ; BG color
         STA $7E3049,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         STA $2122       ; Put LB in CGRAM
         XBA             ; Switch to HB
         STA $2122       ; Put HB in CGRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$00A0      ; Done 80 colors?
         BNE C37382      ; Loop if not
         RTS

; Load portrait colors for entire party
C3739D:  LDX $00         ; Member index: 0
         TXY             ; Dest index: 0
C373A0:  REP #$20        ; 16-bit A
         LDA $6D,X       ; Actor data index
         PHX             ; Save member index
         PHY             ; Save dest index
         TAY             ; Actor data index
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA #$10        ; Colors: 16
         STA $E3         ; Set counter
         LDA $0014,Y     ; Status
         AND #$20        ; Imp?
         BEQ C373B9      ; Branch if not
         LDA #$0F        ; Use Imp data
         BRA C373C4      ; Ignore actor
C373B9:  TDC             ; ...
         LDA $0000,Y     ; Actor
         CMP #$01        ; Locke?
         BEQ C373C4      ; Branch if so
         LDA $0001,Y     ; Graphics set
C373C4:  TAX             ; Index it
         LDA.L C37694,X  ; Palette number
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         TAX             ; Index it
         PLY             ; RAM index
C373D2:  REP #$20        ; 16-bit A
         PHX             ; Save ROM index
         LDA $ED5860,X   ; Portrait color
         TYX             ; RAM index
         STA $7E3149,X   ; Set color
         SEP #$20        ; 8-bit A
         PLX             ; ROM index
         INX             ; ROM index +1
         INX             ; ROM index +1
         INY             ; RAM index +1
         INY             ; RAM index +1
         DEC $E3         ; One less color
         BNE C373D2      ; Loop till last
         PLX             ; Member index
         INX             ; Member index +1
         INX             ; Member index +1
         CPX #$0008      ; Done 4 members?
         BNE C373A0      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Load grayscale actor palette
C373F4:  LDA #$90        ; Object color 16
         STA $2121       ; CGRAM: $0120
         LDX $00         ; Color index: 0
C373FB:  REP #$20        ; 16-bit A
         LDA $D8E8A0,X   ; Grayscale color
         STA $7E3169,X   ; To OBJ pal 1
         SEP #$20        ; 8-bit A
         STA $2122       ; Put LB in CGRAM
         XBA             ; Switch to HB
         STA $2122       ; Put HB in CGRAM
         INY             ; ...
         INY             ; ...
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 colors?
         BNE C373FB      ; Loop if not
         RTS

; Load cursor, arrow, and icon colors
C37418:  LDX $00         ; Color index: 0
         LDA #$EC        ; Object color 108
         STA $2121       ; CGRAM: $01D8
C3741F:  REP #$20        ; 16-bit A
         LDA $D8E8C0,X   ; Status icon color
         STA $7E3221,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         STA $2122       ; Put LB in CGRAM
         XBA             ; Switch to HB
         STA $2122       ; Put HB in CGRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0008      ; Done 4 colors?
         BNE C3741F      ; Loop if not
         LDX $00         ; Color index: 0
         LDA #$FC        ; Object color 124
         STA $2121       ; CGRAM: $01F8
C37440:  REP #$20        ; 16-bit A
         LDA $D8E8B8,X   ; Cursor, etc. color
         STA $7E3241,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         STA $2122       ; Put LB in CGRAM
         XBA             ; Switch to HB
         STA $2122       ; Put HB in CGRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0008      ; Done 4 colors?
         BNE C37440      ; Loop if not
         RTS

; Load actor sprite palettes
C3745B:  LDX $00         ; Color index: 0
         LDA #$A0        ; Object color 32
         STA $2121       ; CGRAM: $0140
C37462:  REP #$20        ; 16-bit A
         LDA $ED6300,X   ; Sprite color
         STA $7E3189,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         STA $2122       ; Put LB in CGRAM
         XBA             ; Switch to HB
         STA $2122       ; Put HB in CGRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$00C0      ; Done 96 colors?
         BNE C37462      ; Loop if not
         RTS

; Upload actor sprite graphics (one pose)
C3747D:  TDC             ; Clear A
         TAX             ; OBJ index: 0
C3747F:  PHX             ; Save index
         REP #$20        ; 16-bit A
         LDA $CFF895,X   ; VRAM pointer			=== SNES: $CFF8E5
         STA $F3         ; Memorize it
         TXA             ; Sprite index
         ASL A           ; Double it
         TAX             ; Index it
         LDA $CFF8C3,X   ; GFX adr LBs			=== SNES: $CFF913
         STA $E7         ; Memorize it
         LDA $CFF8C1,X   ; GFX adr HBs			=== SNES: $CFF911
         STA $E9         ; Memorize it
         LDX $00         ; Ptr index: 0

; Fork: Head and torso
C37499:  LDA $CFF88F,X   ; Tile rel ptr			=== SNES: $CFF8DF
         STA $EF         ; Memorize it
         JSR C374D8      ; Load 2 tiles
         LDA $F3         ; VRAM pointer
         CLC             ; Prepare ADC
         ADC #$0100      ; Go 1 row down
         STA $F3         ; Save changes
         INX             ; Ptr index +1
         INX             ; Ptr index +1
         CPX #$0004      ; Done 2 rows?
         BNE C37499      ; Loop if not

; Fork: Legs
C374B1:  LDA $F3         ; VRAM pointer
         SEC             ; Prepare SBC
         SBC #$01E0      ; Row -2, col +2
         STA $F3         ; Save changes
         LDA $CFF88F,X   ; Tile rel ptr			=== SNES: $CFF8DF
         STA $EF         ; Memorize it
         JSR C374D8      ; Load leg GFX

; Fork: Blank row
C374C2:  LDA $F3         ; VRAM pointer
         CLC             ; Prepare ADC
         ADC #$0100      ; Go 1 row down
         STA $F3         ; Save changes
         JSR C374FB      ; Blank 4th row

; Fork: Handle next sprite
C374CD:  PLX             ; Sprite index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$002C      ; 22th sprite?
         BNE C3747F      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Upload both tiles in current row of actor sprite
C374D8:  CLC             ; Prepare ADC
         LDA $EF         ; Tile rel pointer
         ADC $E7         ; Add base adr LBs
         STA $EB         ; Set src LBs
         TDC             ; Zero A
         ADC $E9         ; Add adr HBs + C
         STA $ED         ; Set source HBs
         LDY $F3         ; VRAM pointer
         STY $2116       ; Set destination
         JMP C374EC      ; ...
C374EC:  LDY $00         ; Index: 0
C374EE:  LDA [$EB],Y     ; Tile graphics
         STA $2118       ; Save in VRAM
         INY             ; Index +1
         INY             ; Index +1
         CPY #$0040      ; Done 2 tiles?
         BNE C374EE      ; Loop if not
         RTS

; Blank both tiles under actor's feet
C374FB:  LDY $F3         ; VRAM pointer
         STY $2116       ; Set destination
         LDA #$0020      ; Tiles: 2
         STA $E7         ; Set counter
C37505:  STZ $2118       ; 8 px, 2 planes
         DEC $E7         ; Counter -1
         BNE C37505      ; Loop till zero
         RTS

; Upload actor sprites for shop
C3750D:  LDY #$3000      ; $3000
         STY $2116       ; Set VRAM ptr
         STZ $E3         ; Actor slot: 1

; Fork: Load both poses for two actors
C37515:  LDY $00         ; Tile slot: 1
C37517:  SEP #$20        ; 8-bit A
         TDC             ; Clear A
         TYX             ; Tile slot
         LDA.L C3759B,X  ; GFX ptr index
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C375BB,X  ; Tile's GFX ptr
         CMP #$FFFF      ; Blank tile?
         BEQ C3757E      ; Blank if so
         PHA             ; Save pointer
         LDA #$16A0      ; GFX struct size
         SEP #$20        ; 8-bit A
         STA $211B       ; Set matrix A LB
         XBA             ; Struct size HB
         STA $211B       ; Set matrix A HB
         LDA $E3         ; Actor A's slot
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         REP #$20        ; 16-bit A
         PLA             ; Tile GFX ptr
         CLC             ; Prepare ADC
         ADC $2134       ; Add product LBs
         STA $EB         ; Set source LBs
         SEP #$20        ; 8-bit A
         LDA $2136       ; Product HB
         ADC #$D5        ; Add base bank
         STA $ED         ; Set source HB
         REP #$21        ; ...
         LDA $EB         ; ...
         ADC #$0000      ; ...
         STA $EB         ; ...
         SEP #$20        ; ...
         LDA $ED         ; ...
         ADC #$00        ; ...
         STA $ED         ; ...
         REP #$20        ; 16-bit A
         PHY             ; Save tile slot
         JSR C3758C      ; Load tile's GFX
         PLY             ; Tile slot
C3756B:  INY             ; Tile slot +1
         CPY #$0020      ; Done 32 tiles?
         BNE C37517      ; Loop if not

; Fork: Handle next two actors
C37571:  SEP #$20        ; 8-bit A
         INC $E3         ; Actor slot +1
         INC $E3         ; Actor slot +1
         LDA $E3         ; Actor slot
         CMP #$10        ; Handled 16?
         BNE C37515      ; Loop if not
         RTS

; Fork: Create a blank tile
C3757E:  LDA #$0010      ; Rows: 8
         STA $E7         ; Set counter
C37583:  STZ $2118       ; 8 px, 2 planes
         DEC $E7         ; Counter -1
         BNE C37583      ; Loop till zero
         BRA C3756B      ; Do next tile

; Upload current actor sprite tile for shop
C3758C:  LDY $00         ; Index: 0
C3758E:  LDA [$EB],Y     ; 8 px, 2 planes
         STA $2118       ; Save in VRAM
         INY             ; Index +1
         INY             ; Index +1
         CPY #$0020      ; Done 8 rows?
         BNE C3758E      ; Loop if not
         RTS

; Indices for loading tiles from two shop actors
C3759B:  db $00          ; Actor1 X1,Y1 (hands down)
         db $01          ; Actor1 X1,Y2 (hands down)
         db $04          ; Actor1 X3,Y1 (hands down)
         db $05          ; Actor1 X3,Y2 (hands down)
         db $08          ; Actor1 X1,Y1 (hands up)
         db $09          ; Actor1 X1,Y2 (hands up)
         db $0C          ; Actor1 X3,Y1 (hands up)
         db $0D          ; Actor1 X3,Y2 (hands up)
         db $10          ; Actor2 X1,Y1 (hands down)
         db $11          ; Actor2 X1,Y2 (hands down)
         db $14          ; Actor2 X3,Y1 (hands down)
         db $15          ; Actor2 X3,Y2 (hands down)
         db $18          ; Actor2 X1,Y1 (hands up)
         db $19          ; Actor2 X1,Y2 (hands up)
         db $1C          ; Actor2 X3,Y1 (hands up)
         db $1D          ; Actor2 X3,Y2 (hands up)
         db $02          ; Actor1 X2,Y1 (hands down)
         db $03          ; Actor1 X2,Y2 (hands down)
         db $06          ; Actor1 X4,Y1 (hands down)
         db $07          ; Actor1 X4,Y2 (hands down)
         db $0A          ; Actor1 X2,Y1 (hands up)
         db $0B          ; Actor1 X2,Y2 (hands up)
         db $0E          ; Actor1 X4,Y1 (hands up)
         db $0F          ; Actor1 X4,Y2 (hands up)
         db $12          ; Actor2 X2,Y1 (hands down)
         db $13          ; Actor2 X2,Y2 (hands down)
         db $16          ; Actor2 X4,Y1 (hands down)
         db $17          ; Actor2 X4,Y2 (hands down)
         db $1A          ; Actor2 X2,Y1 (hands up)
         db $1B          ; Actor2 X2,Y2 (hands up)
         db $1E          ; Actor2 X4,Y1 (hands up)
         db $1F          ; Actor2 X4,Y2 (hands up)

; Tile graphics pointers for odd-numbered shop actors
C375BB:  dw $03C0        ; 1,1 (hands down)
         dw $03E0        ; 1,2 (hands down)
         dw $0500        ; 2,1 (hands down)
         dw $0520        ; 2,2 (hands down)
         dw $0540        ; 3,1 (hands down)
         dw $0560        ; 3,2 (hands down)
         dw $FFFF        ; 4,1 (hands down)
         dw $FFFF        ; 4,2 (hands down)
         dw $03C0        ; 1,1 (hands up)
         dw $0660        ; 1,2 (hands up)
         dw $0680        ; 2,1 (hands up)
         dw $06A0        ; 2,2 (hands up)
         dw $06C0        ; 3,1 (hands up)
         dw $06E0        ; 3,2 (hands up)
         dw $FFFF        ; 4,1 (hands up)
         dw $FFFF        ; 4,2 (hands up)

; Tile graphics pointers for even-numbered shop actors
C375DB:  dw $1A60        ; 1,1 (hands down)
         dw $1A80        ; 1,2 (hands down)
         dw $1BA0        ; 2,1 (hands down)
         dw $1BC0        ; 2,2 (hands down)
         dw $1BE0        ; 3,1 (hands down)
         dw $1C00        ; 3,2 (hands down)
         dw $FFFF        ; 4,1 (hands down)
         dw $FFFF        ; 4,2 (hands down)
         dw $1A60        ; 1,1 (hands up)
         dw $1D00        ; 1,2 (hands up)
         dw $1D20        ; 2,1 (hands up)
         dw $1D40        ; 2,2 (hands up)
         dw $1D60        ; 3,1 (hands up)
         dw $1D80        ; 3,2 (hands up)
         dw $FFFF        ; 4,1 (hands up)
         dw $FFFF        ; 4,2 (hands up)

; Upload cursor, arrow, and icon graphics (plus excess data)
C375FB:  REP #$20        ; 16-bit A
         LDY #$2000      ; $2000
         STY $2116       ; Set VRAM ptr
         LDX $00         ; Index: 0
C37605:  LDA $ED5AC0,X   ; 8 px, 2 planes
         STA $2118       ; Save in VRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX #$1400      ; At ED/6EC0?
         BNE C37605      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Upload each member's portrait
C37616:  LDX $00         ; 1st: Member 1
C37618:  REP #$20        ; 16-bit A
         LDA.L C376E5,X  ; VRAM pointer
         STA $2116       ; Set destination
         LDY $6D,X       ; Actor's address
         PHX             ; Save mbr index
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $0014,Y     ; Status
         AND #$20        ; Imp?
         BEQ C37632      ; Branch if not
         LDA #$0F        ; Use Imp image
         BRA C3763C      ; Ignore actor
C37632:  LDA $0000,Y     ; Actor
         CMP #$01        ; Locke?
         BEQ C3763C      ; Branch if so
         LDA $0001,Y     ; Graphics set
C3763C:  REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C376AF,X  ; GFX pointer
         TAX             ; Index it
         JSR C37794      ; Upload portrait
         PLX             ; Member index
         INX             ; Member index +1
         INX             ; Member index +1
         CPX #$0008      ; Done 4 members?
         BNE C37618      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Set to upload healed member's portrait
C37653:  LDA #$ED        ; Bank: ED
         STA $1F         ; Set src HB
         LDY #$0320      ; Bytes: 800
         STY $19         ; Set data size
         TDC             ; Clear A
         LDA $9C         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C376E5,X  ; VRAM pointer
         STA $1B         ; Set destination
         LDY $6D,X       ; Actor's address
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $0014,Y     ; Status
         AND #$20        ; Imp?
         BEQ C37679      ; Branch if not
         LDA #$0F        ; Use Imp image
         BRA C37683      ; Ignore actor
C37679:  LDA $0000,Y     ; Actor
         CMP #$01        ; Locke?
         BEQ C37683      ; Branch if so
         LDA $0001,Y     ; Graphics set
C37683:  REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C376AF,X  ; GFX pointer
         CLC             ; ...
         ADC #$1D00      ; Add base adr
         STA $1D         ; Set src LBs
         SEP #$20        ; 8-bit A
         RTS

; Portrait palette assignments
C37694:  db $00          ; 00: Terra
         db $01          ; 01: Locke
         db $02          ; 02: Cyan
         db $03          ; 03: Shadow
         db $04          ; 04: Edgar
         db $05          ; 05: Sabin
         db $06          ; 06: Celes
         db $07          ; 07: Strago
         db $08          ; 08: Relm
         db $09          ; 09: Setzer
         db $0A          ; 0A: Moogle
         db $0B          ; 0B: Gau
         db $0C          ; 0C: Gogo
         db $0D          ; 0D: Umaro
         db $0E          ; 0E: Soldier
         db $0F          ; 0F: Imp
         db $10          ; 10: Leo
         db $11          ; 11: Banon
         db $00          ; 12: Terra (unused; esper Terra)
         db $0E          ; 13: Soldier (unused; merchant)
         db $12          ; 14: Ghost
         db $00          ; 15: Terra (unused; Kefka)
         db $00          ; 16: Terra (unused; Gestahl)
         db $00          ; 17: Terra (unused; Gungho)
         db $00          ; 18: Terra (unused; Duane)
         db $00          ; 19: Terra (unused; dog)
         db $06          ; 1A: Celes (unused; Maria)

; Pointers to portrait graphics
C376AF:  dw $0000        ; 00: Terra
         dw $0320        ; 01: Locke
         dw $0640        ; 02: Cyan
         dw $0960        ; 03: Shadow
         dw $0C80        ; 04: Edgar
         dw $0FA0        ; 05: Sabin
         dw $12C0        ; 06: Celes
         dw $15E0        ; 07: Strago
         dw $1900        ; 08: Relm
         dw $1C20        ; 09: Setzer
         dw $1F40        ; 0A: Mog
         dw $2260        ; 0B: Gau
         dw $2580        ; 0C: Gogo
         dw $28A0        ; 0D: Umaro
         dw $2BC0        ; 0E: Soldier
         dw $2EE0        ; 0F: Imp
         dw $3200        ; 10: Leo
         dw $3520        ; 11: Banon
         dw $0000        ; 12: Terra (unused; esper Terra)
         dw $2BC0        ; 13: Soldier (unused; merchant)
         dw $3840        ; 14: Ghost
         dw $0000        ; 15: Terra (unused; Kefka)
         dw $0000        ; 16: Terra (unused; Gestahl)
         dw $0000        ; 17: Terra (unused; Gungho)
         dw $0000        ; 18: Terra (unused; Duane)
         dw $0000        ; 19: Terra (unused; dog)
         dw $12C0        ; 1A: Celes (unused; Maria)

; VRAM pointers for portrait graphics
C376E5:  dw $2600        ; Member 1
         dw $2800        ; Member 2
         dw $2A00        ; Member 3
         dw $2C00        ; Member 4
         dw $2E00        ; Bogus...
         dw $3000        ; Bogus...
         dw $3200        ; Bogus...
         dw $3400        ; Bogus...

; List actor sprites for save file 1
C376F5:  LDY $91         ; Blank file?
         BEQ C37714      ; Nobody if so
         LDX $00         ; Member slot: 1
C376FB:  LDA $69,X       ; Actor in slot
         BMI C37707      ; Blank if none
         JSR C3772B      ; Get sprite set
         JSR C3773A      ; Handle soldier
         BRA C37709      ; Skip a line
C37707:  LDA #$FF        ; Sprite: None
C37709:  STA $7EAA71,X   ; Set sprite
         INX             ; Member slot +1
         CPX #$0004      ; Done all 4?
         BNE C376FB      ; Loop if not
         RTS

; Fork: Empty party
C37714:  LDX $00         ; Sprites: 1-4
         BRA C37718      ; ...
C37718:  LDA #$FF        ; Sprite: None
         STA $7EAA71,X   ; Set sprite A
         STA $7EAA72,X   ; Set sprite B
         STA $7EAA73,X   ; Set sprite C
         STA $7EAA74,X   ; Set sprite D
         RTS

; Get actor's graphics set
C3772B:  PHX             ; Save X
         REP #$20        ; 16-bit A
         TXA             ; Actor number
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor's address
         SEP #$20        ; 8-bit A
         PLX             ; Restore X
         LDA $0001,Y     ; Graphics set
         RTS

; Choose between green or brown soldier
C3773A:  CMP #$0E        ; Soldier sprite?
         BNE C3774B      ; Exit if not
         LDA $1EA0       ; Event flags
         BIT #$08        ; Soldier disguise?
         BEQ C37749      ; Pick brown if not
         LDA #$16        ; Use green soldier
         BRA C3774B      ; Exit
C37749:  LDA #$0E        ; Use brown soldier
C3774B:  RTS

; List actor sprites for save file 2
C3774C:  LDY $93         ; Blank file?
         BEQ C3776B      ; Nobody if so
         LDX $00         ; Member slot: 1
C37752:  LDA $69,X       ; Actor in slot
         BMI C3775E      ; Blank if none
         JSR C3772B      ; Get sprite set
         JSR C3773A      ; Handle soldier
         BRA C37760      ; Skip a line
C3775E:  LDA #$FF        ; Sprite: None
C37760:  STA $7EAA75,X   ; Set sprite
         INX             ; Member slot +1
         CPX #$0004      ; Done all 4?
         BNE C37752      ; Loop if not
         RTS

; Fork: Empty party
C3776B:  LDX #$0004      ; Sprites: 5-8
         BRA C37718      ; Blank sprites

; List actor sprites for save file 3
C37770:  LDY $95         ; Blank file?
         BEQ C3778F      ; Nobody if so
         LDX $00         ; Member slot: 1
C37776:  LDA $69,X       ; Actor in slot
         BMI C37782      ; Blank if none
         JSR C3772B      ; Get sprite set
         JSR C3773A      ; Handle soldier
         BRA C37784      ; Skip a line
C37782:  LDA #$FF        ; Sprite: None
C37784:  STA $7EAA79,X   ; Set sprite
         INX             ; Member slot +1
         CPX #$0004      ; Done all 4?
         BNE C37776      ; Loop if not
         RTS

; Fork: Empty party
C3778F:  LDX #$0008      ; Sprites: 9-12
         BRA C37718      ; Blank sprites

; Upload actor's portrait graphics
C37794:  LDY #$0190      ; Tiles: 25
C37797:  LDA $ED1D00,X   ; 8 px, 2 planes
         STA $2118       ; Save in VRAM
         INX             ; Index +1
         INX             ; Index +1
         DEY             ; One less word
         BNE C37797      ; Loop till last
         RTS

; Create a blank portrait for Lineup menu
C377A4:  LDX #$9F51      ; 7E/9F51
         STX $2181       ; Set WRAM LBs
         LDX #$0190      ; Tiles: 25
C377AD:  STZ $2180       ; 8 px, 1 plane
         STZ $2180       ; 8 px, 1 plane
         DEX             ; One less word
         BNE C377AD      ; Loop till last
         RTS

; Validate SRAM markers
C377B7:  REP #$20        ; 16-bit A
         LDA #$E41B      ; Square's marker
         CMP $307FF8     ; In file A?
         BEQ C377DB      ; Okay if so
         CMP $307FFA     ; In file B?
         BEQ C377DB      ; Okay if so
         CMP $307FFC     ; In file C?
         BEQ C377DB      ; Okay if so
         CMP $307FFE     ; In file D?...
         BEQ C377DB      ; Okay if so
         SEP #$20        ; 8-bit A
         JSR C377DF      ; Delete all SRAM
         CLC             ; Skip Load menu
         RTS             ; Exit
C377DB:  SEP #$20        ; 8-bit A
         SEC             ; Call Load menu
         RTS

; Delete all saved data
C377DF:  PHB             ; Save DB
         LDA #$30        ; Bank: 30
         PHA             ; Put on stack
         PLB             ; Set DB to 30
         LDX #$0000      ; SRAM index: 0
         REP #$20        ; 16-bit A
C377E9:  STZ $6000,X     ; Clear SRAM word
         INX             ; Index +1
         INX             ; Index +1
         STZ $6000,X     ; Clear SRAM word
         INX             ; Index +1
         INX             ; Index +1
         CPX #$2000      ; Fully cleared?
         BNE C377E9      ; Loop if not
         SEP #$20        ; 8-bit A
         PLB             ; Restore DB
         RTS

; Reset saved cursor positions for main menu
C377FC:  LDX #$0000      ; Index: 0
C377FF:  STZ $022B,X     ; Clear position
         INX             ; Point to next
         CPX #$001F      ; Past $0249?
         BNE C377FF      ; Loop if not
         LDA #$01        ; Skills: "Magic"
         STA $0237       ; Set for ally 1
         STA $0239       ; Set for ally 2
         STA $023B       ; Set for ally 3
         STA $023D       ; Set for ally 4
         RTS

; Mark all save files as Square's property
C37817:  REP #$20        ; 16-bit A
         LDA #$E41B      ; Square marker
         STA $307FF8     ; Mark file A
         STA $307FFA     ; Mark file B
         STA $307FFC     ; Mark file C
         STA $307FFE     ; No file D...
         SEP #$20        ; 8-bit A
         RTS

; Reset game data for Load menu
C3782F:  JSR C377FC      ; Clear cursor mem
         LDY #$7FFF      ; Color: White
         STY $1D55       ; Set user font's
         LDA #$12        ; Buttons: A & B
         STA $1D50       ; Define purpose
         LDA #$34        ; Buttons: X & Y
         STA $1D51       ; Define purpose
         LDA #$56        ; Buttons: L & R
         STA $1D52       ; Define purpose
         LDA #$06        ; Button: Select
         STA $1D53       ; Define purpose
         LDA #$2A        ; Bat.Mode, etc.
         STA $1D4D       ; Define options
         TDC             ; Clear A
         TAY             ; Clear Y
         STY $1DC7       ; Save count: 0
         STZ $1D54       ; Mag.Order, etc.
         STZ $1D4E       ; Wallpaper, etc.
         STZ $1D4F       ; Pad assignments
         STY $1863       ; SRAM hours, mins
         STZ $1865       ; SRAM seconds
         STY $1860       ; Gold LBs
         STZ $1862       ; Gold HB
         STY $1866       ; Steps LBs
         STZ $1868       ; Steps HB
         STY $021B       ; Real hours, mins
         STY $021D       ; Real secs, frames
         JSR C37350      ; Reset skin colors
         RTS

; 2C: Initialize Lineup menu
C3787B:  JSR C37890      ; Init variables
         STZ $4A         ; Cursor area: Top
         STZ $5A         ; Always 0...
         STZ $99         ; Always 0...
         JSR C37DBE      ; List/Create actors
         JSR C37C16      ; Load navig data
         JSR C37C1F      ; Relocate cursor
         JMP C378A8      ; Draw menu, etc.

; Initialize variables for Lineup menu
C37890:  JSR C335F7      ; Reset/Stop stuff
         JSR C37076      ; Reset BGs' X/Y
         LDA #$03        ; 64x64 at $0000
         STA $2107       ; Set BG1 map loc
         LDA #$C0        ; Channels: 6, 7
         TRB $43         ; Halt HDMA 6+7...
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         LDA #$06        ; Status icons: Temp
         TSB $47         ; Set menu flag
         RTS

; Draw Lineup menu, etc.
C378A8:  JSR C30833      ; Queue cursor OAM
         JSR C37D59      ; Set to shift text
         JSR C37CB6      ; Draw boxes/title
         JSR C380D3      ; Create portrait
         JSR C380E7      ; Draw actor info
         JSR C30F68      ; Queue text upload
         LDA #$2D        ; C3/78FC
         STA $27         ; Queue: Choice 1
         LDA #$66        ; C3/8193
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 7D: Return to Lineup menu from Status menu
C378C5:  JSR C37890      ; Init variables
         LDA $5D         ; Backup of $99
         STA $99         ; Always 0...
         JSR C37E0B      ; Create/lock chars
         LDA $90         ; Go to party area?
         BNE C378DF      ; Branch if so
         JSR C37C16      ; Load navig data
         LDY $8E         ; Old cursor loc
         STY $4D         ; Set as current
         JSR C37C1F      ; Relocate cursor
         BRA C378F9      ; Draw menu, etc.

; Fork: Back to party area
C378DF:  LDA $90         ; ...
         STA $4A         ; Cursor area: Top
         LDA $8D         ; Backup of $5A
         STA $5A         ; Always 0...
         JSR C37B6F      ; Relocate cursor
         LDY $8E         ; Old cursor loc
         STY $4D         ; Set as current
         LDA $79         ; Cursor wrap flags
         STA $59         ; Restore them
         LDY $7A         ; Row/Col count
         STY $53         ; Restore format
         JSR C37BA9      ; Handle D-Pad
C378F9:  JMP C378A8      ; Draw menu, etc.

; 2D: Handle Lineup menu choice 1
C378FC:  JSR C3794D      ; Cover D-Pad/stats
         BCC C3794C      ; If crossed center
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3793D      ; Branch if not
         LDA $4B         ; Cursor slot
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if on party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $7EAC8D,X   ; Locked slot?
         BMI C37936      ; Fail if so
         JSR C30F1D      ; Sound: Click
         LDA $4B         ; Cursor slot
         STA $28         ; Set pick 1's
         LDA $4A         ; Cursor area
         STA $49         ; Set pick 1's
         LDA $5A         ; Always 0...
         STA $5B         ; Ditto...
         LDA #$2E        ; C3/79A0
         STA $26         ; Next: Choice 2
         JSR C32FBC      ; Create blinker
         LDA $4A         ; In party area?
         BEQ C37935      ; Exit if not
         LDA #$02        ; Anim mode: 2
         STA $7E3649,X   ; Set blinker's
C37935:  RTS

; Fork: Forced member
C37936:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Fork: Exit attempt
C3793D:  LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BNE C37949      ; Branch if so
         LDA $09         ; ...
         BIT #$80        ; Pushing B?
         BEQ C3794C      ; Exit if not
C37949:  JSR C37A2A      ; Validate groups
C3794C:  RTS

; Handle D-Pad and update actor info in Lineup menu
C3794D:  JSR C37D4C      ; Update char info
         LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C37972      ; Branch if not
         LDA $4E         ; Cursor row
         CMP #$01        ; 2nd or 4th?
         BNE C37972      ; Branch if not
         LDA $4A         ; In party area?
         BNE C37972      ; Branch if so

; Fork: Enter party area
C37960:  LDA #$10        ; Cursor slot: +16
         STA $4A         ; Set area mod
         LDA $99         ; Always 0...
         ASL A           ; x2...
         ASL A           ; x4...
         STA $5A         ; Always 0...
         JSR C37B6F      ; Relocate cursor
         JSR C30F0E      ; Sound: Cursor
         CLC             ; Mark area exit
         RTS

; Fork: Handle up
C37972:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C3799A      ; Branch if not
         LDA $4E         ; On row 1 or 3?
         BNE C3799A      ; Branch if not
         LDA $4A         ; In party area?
         BEQ C3799A      ; Branch if not

; Fork: Exit party area
C37980:  LDA $4D         ; Cursor column
         STA $5E         ; Set as former
         STZ $4A         ; Cursor area: Top
         STZ $5A         ; Always 0...
         JSR C37C16      ; Load navig data
         LDA #$01        ; Row: 2nd
         STA $4E         ; Set cursor row
         JSR C37BE0      ; Adjust column
         JSR C37C1F      ; Relocate cursor
         JSR C30F0E      ; Sound: Cursor
         CLC             ; Mark area exit
         RTS

; Fork: Staying within same area
C3799A:  JSR C37BA9      ; Handle D-Pad
         SEC             ; Unmark area exit
         RTS             ; ...
C3799F:  RTS

; 2E: Handle Lineup menu choice 2
C379A0:  JSR C3794D      ; Cover D-Pad/stats
         BCC C3799F      ; If crossed center
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C37A11      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; Cursor slot B
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if on party
         ADC $5A         ; Always 0...
         STA $E0         ; Memorize sum
         TAX             ; Index it
         LDA $7EAC8D,X   ; Locked slot?
         BMI C37A23      ; Fail if so
         TDC             ; Clear A
         LDA $28         ; Cursor slot A
         CLC             ; Prepare ADC
         ADC $49         ; +16 if on party
         ADC $5B         ; Always 0...
         CMP $E0         ; Slots are same?
         BNE C379F9      ; Swap chars if not

; Fork: Double-clicked a slot
C379C8:  LDA $E0         ; Chosen slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Empty slot?
         BMI C37A0B      ; Fail if so
         JSR C30F1D      ; Sound: Click
         LDA $59         ; Cursor wrap flags
         STA $79         ; Make backup copy
         LDY $53         ; Rows/Cols count
         STY $7A         ; Make backup copy
         LDY $4D         ; Cursor position
         STY $8E         ; Set return loc
         LDA $4A         ; Area indicator
         STA $90         ; Set for return
         LDA $5A         ; Always 0...
         STA $8D         ; Make a backup
         LDA $99         ; Always 0...
         STA $5D         ; Make a backup
         LDA #$42        ; C3/6966
         STA $27         ; Queue Status menu
         LDA #$67        ; C3/8184
         STA $26         ; Next: Fade-out
         LDA #$7D        ; C3/78C5
         STA $4C         ; Set return cmd
         RTS

; Fork: Swap slot contents
C379F9:  JSR C30F1D      ; Sound: Click
         LDA #$07        ; Actors: Delete
         TRB $47         ; Set menu flag
         JSR C37A8C      ; Swap positions
         JSR C3121B      ; Delete actors
         JSR C37DA7      ; Create actors
         BRA C37A1A      ; Next: Choice 1

; Fork: Double-clicked empty slot
C37A0B:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen

; Fork: Handle B
C37A11:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C37A22      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C37A1A:  LDA #$2D        ; C3/78FC
         STA $26         ; Next: Choice 1
         LDA #$05        ; Blinker: Off
         TRB $46         ; Set menu flag
C37A22:  RTS

; Fork: Forced member
C37A23:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Handle attempt to exit Lineup menu
C37A2A:  TDC             ; Clear A
         TAX             ; Slot index: 0
         LDA $0201       ; Group count
         AND #$7F        ; Clear flag
         ASL A           ; x2
         ASL A           ; x4 members
         STA $F3         ; Set index cap
         STZ $F4         ; Clear its HB
C37A37:  STZ $E0         ; Members: 0
         LDY #$0004      ; Slots left: 4
C37A3C:  LDA $7E9D99,X   ; Empty slot?
         BMI C37A44      ; Branch if so
         INC $E0         ; +1 member
C37A44:  INX             ; Slot index +1
         DEY             ; One less slot
         BNE C37A3C      ; Loop till 4th
         LDA $E0         ; Empty party?
         BEQ C37A5F      ; Fail if so
         CPX $F3         ; Last party?
         BNE C37A37      ; Loop if not
         JSR C30F14      ; Sound: Cursor
         STZ $0205       ; Never read...
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         LDA #$67        ; C3/8184
         STA $26         ; Next: Fade-out
         RTS

; Fork: Draw "You need <#> group(s)."
C37A5F:  JSR C30F2B      ; Play buzzer
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDA $0201       ; Event data
         AND #$07        ; Group count
         CMP #$01        ; One group?
         BEQ C37A7D      ; Branch if so
         LDY #C38244     ; Text pointer
         JSR C30326      ; Draw message
         LDX #$392F      ; Tilemap pointer
         JSR C37D8B      ; Draw group count
         BRA C37A83      ; Skip 2 lines

; Fork: Draw "No one there!"
C37A7D:  LDY #C38258     ; Text pointer
         JSR C30326      ; Draw message
C37A83:  LDA #$20        ; Frames: 32
         STA $20         ; Set wait timer
         LDA #$69        ; C3/821B
         STA $26         ; Next: Wait
         RTS

; Swap actor positions in Lineup menu
C37A8C:  TDC             ; Clear A
         LDA $28         ; Chosen slot A
         CLC             ; Prepare ADC
         ADC $49         ; +16 if on party
         ADC $5B         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot A
         STA $E5         ; Memorize it
         BPL C37AAB      ; Branch if any

; Fork: Fake party info for empty slot A
C37A9D:  LDA $7E9E51,X   ; Party number
         ORA.L C37B43,X  ; Add roster slot
         STA $E0         ; Memorize it
         STZ $E1         ; Clear row...
         BRA C37ABA      ; Handle slot B

; Fork: Get party info of actor A
C37AAB:  TAY             ; Index actor A
         LDA $1850,Y     ; Party info
         AND #$DF        ; Discard row
         STA $E0         ; Memorize it
         LDA $1850,Y     ; Party info
         AND #$20        ; Isolate row
         STA $E1         ; Memorize it

; Fork: Get actor in slot B
C37ABA:  LDA $4B         ; Chosen slot B
         CLC             ; ...
         ADC $4A         ; +16 if on party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot B
         STA $E6         ; Memorize it
         BPL C37AD8      ; Branch if any

; Fork: Fake party info for empty slot B
C37ACA:  LDA $7E9E51,X   ; Party number
         ORA.L C37B43,X  ; Add roster slot
         STA $E2         ; Memorize it
         STZ $E3         ; Clear row...
         BRA C37AE7      ; Swap positions

; Fork: Get party info of actor B
C37AD8:  TAY             ; Index actor B
         LDA $1850,Y     ; Party info
         AND #$DF        ; Discard row
         STA $E2         ; Memorize it
         LDA $1850,Y     ; Party info
         AND #$20        ; Isolate row
         STA $E3         ; Memorize it

; Fork: Swap slot positions
C37AE7:  LDA $E0         ; Actor A info
         AND #$40        ; Object is on?
         BNE C37AF5      ; Branch if so
C37AED:  LDA $E2         ; Actor B info
         AND #$40        ; Object is on?
         BNE C37B0E      ; Branch if so
         BRA C37B25      ; Swap menu slots

; Fork: Update party info for actor A
C37AF5:  TDC             ; ...
         LDA $28         ; Chosen slot A
         CLC             ; Prepare ADC
         ADC $49         ; +16 if on party
         ADC $5B         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot A
         BMI C37AED      ; Branch if none
         TAX             ; Index it
         LDA $E2         ; Actor B info
         ORA $E1         ; Add A's row
         STA $1850,X     ; Set A's info
         BRA C37AED      ; Repeat for B

; Fork: Update party info for actor B
C37B0E:  TDC             ; ...
         LDA $4B         ; Chosen slot B
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if on party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot B
         BMI C37B25      ; Branch if none
         TAX             ; Index it
         LDA $E0         ; Actor A info
         ORA $E3         ; Add B's row
         STA $1850,X     ; Set B's info

; Fork: Swap slot contents
C37B25:  TDC             ; ...
         LDA $4B         ; Chosen slot B
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if in party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $E5         ; Actor in slot A
         STA $7E9D89,X   ; Put in slot B
         LDA $28         ; Chosen slot A
         CLC             ; Prepare ADC
         ADC $49         ; +16 if in party
         ADC $5B         ; Always 0...
         TAX             ; Index sum
         LDA $E6         ; Actor in slot B
         STA $7E9D89,X   ; Put in slot A
         RTS

; Roster position and object status for Lineup menu slots
C37B43:  db $40          ; Non-party slot 1
         db $40          ; Non-party slot 2
         db $40          ; Non-party slot 3
         db $40          ; Non-party slot 4
         db $40          ; Non-party slot 5
         db $40          ; Non-party slot 6
         db $40          ; Non-party slot 7
         db $40          ; Non-party slot 8
         db $40          ; Non-party slot 9
         db $40          ; Non-party slot 10
         db $40          ; Non-party slot 11
         db $40          ; Non-party slot 12
         db $40          ; Non-party slot 13
         db $40          ; Non-party slot 14
         db $40          ; Non-party slot 15
         db $40          ; Non-party slot 16
         db $40          ; Party 1, NW
         db $48          ; Party 1, SW
         db $50          ; Party 1, NE
         db $58          ; Party 1, SE
         db $40          ; Party 2, NW
         db $48          ; Party 2, SW
         db $50          ; Party 2, NE
         db $58          ; Party 2, SE
         db $40          ; Party 3, NW
         db $48          ; Party 3, SW
         db $50          ; Party 3, NE
         db $58          ; Party 3, SE
         db $40          ; Party 4, NW (unused)
         db $48          ; Party 4, SW (unused)
         db $50          ; Party 4, NE (unused)
         db $58          ; Party 4, SE (unused)
         db $40          ; Party 5, NW (unused)
         db $48          ; Party 5, SW (unused)
         db $50          ; Party 5, NE (unused)
         db $58          ; Party 5, SE (unused)
         db $40          ; Party 6, NW (unused)
         db $48          ; Party 6, SW (unused)
         db $50          ; Party 6, NE (unused)
         db $58          ; Party 6, SE (unused)
         db $40          ; Party 7, NW (unused)
         db $48          ; Party 7, SW (unused)
         db $50          ; Party 7, NE (unused)
         db $58          ; Party 7, SE (unused)

; Load nav data for party area of Lineup menu, relocate cursor
C37B6F:  LDA $4D         ; Cursor column
         STA $5E         ; Set as former
         LDA $0201       ; Group count
         AND #$7F        ; Clear flag
         CMP #$01        ; One group?
         BEQ C37B89      ; Branch if so
         CMP #$02        ; Two groups?
         BEQ C37B99      ; Branch if so

; Fork: Three groups
C37B80:  JSR C37C43      ; Load navig data
         JSR C37BC6      ; Set cursor column
         JMP C37C4C      ; Relocate cursor

; Fork: One group
C37B89:  JSR C37C25      ; Load navig data
         LDA $5E         ; Old cursor column
         CMP #$01        ; First column?
         BCC C37B94      ; Retain it if so
         LDA #$01        ; Column: 2nd
C37B94:  STA $4D         ; Set new column
         JMP C37C2E      ; Relocate cursor

; Fork: Two groups
C37B99:  JSR C37C34      ; Load navig data
         LDA $5E         ; Old cursor column
         CMP #$03        ; Within first 3?
         BCC C37BA4      ; Retain it if so
         LDA #$03        ; Column: 4th
C37BA4:  STA $4D         ; Set new column
         JMP C37C3D      ; Relocate cursor

; Handle D-Pad for Lineup menu
C37BA9:  LDA $4A         ; In party area?
         BEQ C37BC3      ; Branch if not
         LDA $0201       ; Group count
         AND #$7F        ; Clear flag
         CMP #$01        ; One group?
         BEQ C37BC0      ; Branch if so
         CMP #$02        ; Two groups?
         BEQ C37BBD      ; Branch if so
         JMP C37C49      ; Handle D-Pad

; Fork: Area with two groups
C37BBD:  JMP C37C3A      ; Handle D-Pad

; Fork: Area with one group
C37BC0:  JMP C37C2B      ; Handle D-Pad

; Fork: Non-party area
C37BC3:  JMP C37C1C      ; Handle D-Pad

; Adjust cursor column upon entering 3-party area of Lineup menu
C37BC6:  LDA $5E         ; Former column
         LDX $00         ; Column index: 0
C37BCA:  CMP.L C37BFA,X  ; On this column?
         BEQ C37BD8      ; Relocate if so
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0010      ; Done 8 columns?
         BNE C37BCA      ; Loop if not
         RTS             ; Exit
C37BD8:  INX             ; Index +1
         LDA.L C37BFA,X  ; Intended column
         STA $4D         ; Set new column
         RTS

; Adjust cursor column upon leaving 3-party area of Lineup menu
C37BE0:  LDA $5E         ; Former column
         LDX $00         ; Column index: 0
C37BE4:  CMP.L C37C0A,X  ; On this column?
         BEQ C37BF2      ; Relocate if so
         INX             ; Index +1
         INX             ; Index +1
         CPX #$000C      ; Done 6 columns?
         BNE C37BE4      ; Loop if not
         RTS             ; Exit
C37BF2:  INX             ; Index +1
         LDA.L C37C0A,X  ; Intended column
         STA $4D         ; Set new column
         RTS

; New cursor column upon entering 3-party area of Lineup menu
C37BFA:  db $00,$00      ; 1 -> 1
         db $01,$01      ; 2 -> 2
         db $02,$01      ; 3 -> 2
         db $03,$02      ; 4 -> 3
         db $04,$03      ; 5 -> 4
         db $05,$04      ; 6 -> 5
         db $06,$04      ; 7 -> 5
         db $07,$05      ; 8 -> 6

; New cursor column upon leaving 3-party area of Lineup menu
C37C0A:  db $00,$00      ; 1 -> 1
         db $01,$01      ; 2 -> 2
         db $02,$03      ; 3 -> 4
         db $03,$04      ; 4 -> 5
         db $04,$06      ; 5 -> 7
         db $05,$07      ; 6 -> 8

; Load navigation data for non-party area of Lineup menu
C37C16:  LDY #C37C52     ; C3/7C52
         JMP C30681      ; Load navig data

; Handle D-Pad for non-party area of Lineup menu
C37C1C:  JSR C307B0      ; Handle D-Pad
C37C1F:  LDY #C37C57     ; C3/7C57
         JMP C306C3      ; Relocate cursor

; Load navigation data for single-party area of Lineup menu
C37C25:  LDY #C37C77     ; C3/7C77
         JMP C30681      ; Load navig data

; Handle D-Pad for single-party area of Lineup menu
C37C2B:  JSR C307B0      ; Handle D-Pad
C37C2E:  LDY #C37C7C     ; C3/7C7C
         JMP C306BA      ; Relocate cursor

; Load navigation data for two-party area of Lineup menu
C37C34:  LDY #C37C84     ; C3/7C84
         JMP C30681      ; Load navig data

; Handle D-Pad for two-party area of Lineup menu
C37C3A:  JSR C307B0      ; Handle D-Pad
C37C3D:  LDY #C37C89     ; C3/7C89
         JMP C306BA      ; Relocate cursor

; Load navigation data for three-party area of Lineup menu
C37C43:  LDY #C37C99     ; C3/7C99
         JMP C30681      ; Load navig data

; Handle D-Pad for three-party area of Lineup menu
C37C49:  JSR C307B0      ; Handle D-Pad
C37C4C:  LDY #C37C9E     ; C3/7C9E
         JMP C306BA      ; Relocate cursor

; Navigation data for non-party area of Lineup menu
C37C52:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $08          ; 8 columns
         db $02          ; 2 rows

; Cursor positions for non-party area of Lineup menu
C37C57:  dw $6408        ; Slot 1
         dw $6424        ; Slot 2
         dw $6440        ; Slot 3
         dw $645C        ; Slot 4
         dw $6478        ; Slot 5
         dw $6494        ; Slot 6
         dw $64B0        ; Slot 7
         dw $64CC        ; Slot 8
         dw $8008        ; Slot 9
         dw $8024        ; Slot 10
         dw $8040        ; Slot 11
         dw $805C        ; Slot 12
         dw $8078        ; Slot 13
         dw $8094        ; Slot 14
         dw $80B0        ; Slot 15
         dw $80CC        ; Slot 16

; Navigation data for single-party area of Lineup menu
C37C77:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $02          ; 2 columns
         db $02          ; 2 rows

; Cursor positions for single-party area of Lineup menu
C37C7C:  dw $A408        ; NW
         dw $A428        ; NE
         dw $C008        ; SW
         dw $C028        ; SE

; Navigation data for two-party area of Lineup menu
C37C84:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $04          ; 4 columns
         db $02          ; 2 rows

; Cursor positions for two-party area of Lineup menu
C37C89:  dw $A408        ; Party 1, NW
         dw $A428        ; Party 1, NE
         dw $A458        ; Party 2, NW
         dw $A478        ; Party 2, NE
         dw $C008        ; Party 1, SW
         dw $C028        ; Party 1, SE
         dw $C058        ; Party 2, SW
         dw $C078        ; Party 2, SE

; Navigation data for three-party area of Lineup menu
C37C99:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $06          ; 6 columns
         db $02          ; 2 rows

; Cursor positions for three-party area of Lineup menu
C37C9E:  dw $A408        ; Party 1, NW
         dw $A428        ; Party 1, NE
         dw $A458        ; Party 2, NW
         dw $A478        ; Party 2, NE
         dw $A4A8        ; Party 3, NW
         dw $A4C8        ; Party 3, NE
         dw $C008        ; Party 1, SW
         dw $C028        ; Party 1, SE
         dw $C058        ; Party 2, SW
         dw $C078        ; Party 2, SE
         dw $C0A8        ; Party 3, SW
         dw $C0C8        ; Party 3, SE

; Draw Lineup menu windows and uppermost text
C37CB6:  LDY #C37D34     ; C3/7D34
         JSR C303C4      ; Draw stats box
         LDY #C37D30     ; C3/7D30
         JSR C303C4      ; Draw bottom box
         LDY #C37D38     ; C3/7D38
         JSR C303C4      ; Draw middle box
         LDY #C37D3C     ; C3/7D3C
         JSR C303C4      ; Draw message box
         LDY #C37D2C     ; C3/7D2C
         JSR C303C4      ; Draw title box
         JSR C37D06      ; Draw party boxes
         JSR C30EBD      ; Upload windows
         JSR C37CF3      ; Clear BG3 map A
         JSR C30ED9      ; Upload BG3 A+B
         JSR C371A9      ; Clear BG1 map A
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDY #C3823D     ; Text pointer
         JSR C30326      ; Draw "Lineup"
         JSR C37CF6      ; Draw "Form..."
         JMP C30E93      ; Upload BG1 A+B

; Clear BG3 tilemap A
C37CF3:  JMP C371D0      ; Clear BG3 map A

; Draw "Form <#> group(s)."
C37CF6:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C38229     ; Text pointer
         JSR C30326      ; Draw "Form..."
         LDX #$3929      ; Tilemap pointer		=== SNES: Shifted leftward
         JMP C37D8B      ; Draw group count

; Draw party windows for Lineup menu
C37D06:  TDC             ; Clear A
         LDA $0201       ; Group count
         AND #$7F        ; Clear flag
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C37D11,X)  ; Draw windows

; Jump table for the above
C37D11:  dw C30000       ; Bogus...
         dw C37D25       ; 1 group
         dw C37D1F       ; 2 groups
         dw C37D19       ; 3 groups

; Draw 3 party windows for Lineup menu
C37D19:  LDY #C37D48     ; C3/7D48
         JSR C303C4      ; Draw party 3 box

; Draw 2 party windows for Lineup menu
C37D1F:  LDY #C37D44     ; C3/7D44
         JSR C303C4      ; Draw party 2 box

; Draw 1 party window for Lineup menu
C37D25:  LDY #C37D40     ; C3/7D40
         JSR C303C4      ; Draw party 1 box
         RTS

; Window layout for Lineup menu
C37D2C:  dw $588B,$0206  ; 08x04 at $588B (Title)
C37D30:  dw $5CCB,$071C  ; 30x09 at $5CCB (Parties)
C37D34:  dw $598B,$051C  ; 30x07 at $598B (Stats)
C37D38:  dw $5B0B,$061C  ; 30x08 at $5B0B (Candidates)
C37D3C:  dw $589B,$0214  ; 22x04 at $589B (Messages)
C37D40:  dw $5D0B,$0608  ; 10x08 at $5D0B (Party 1)
C37D44:  dw $5D1F,$0608  ; 10x08 at $5D1F (Party 2)
C37D48:  dw $5D33,$0608  ; 10x08 at $5D33 (Party 3)

; Update displayed actor info in Lineup menu
C37D4C:  LDA #$06        ; Status icons: Temp
         TSB $47         ; Set menu flag
         JSR C383B6      ; Queue face upload
         JSR C38435      ; Load face colors
         JMP C380E7      ; Draw actor info

; Set to condense text in Lineup menu
C37D59:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$0E        ; $210E
         STA $4351       ; To BG1 V-Scroll
         LDY #C37D78     ; C3/7D78
         STY $4352       ; Set CH5 src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set CH5 src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Text shifting table for the above
C37D78:  db $20,$02,$00  ; Title
         db $08,$00,$00  ; Nothing
         db $0B,$04,$00  ; Nothing
         db $0C,$08,$00  ; Level
         db $0C,$0C,$00  ; HP
         db $0C,$10,$00  ; MP
         db $00          ; End

; Draw number of required groups for Lineup menu
C37D8B:  TDC             ; Clear A
         LDA $0201       ; Event data
         AND #$07        ; Group count
         CLC             ; Prepare ADC
         ADC #$53        ; Turn into text		=== SNES: Different base tile number
         STA $F9         ; Add to string
         STZ $FA         ; End string
         STX $F7         ; Set position
         LDY #$00F7      ; 00/00F7
         STY $E7         ; Set src LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw value
         RTS

; List members and create actors after changes in Lineup menu
C37DA7:  LDA #$FF        ; Actor: None
         LDX $00         ; Member slot: 1
C37DAB:  STA $7E9D99,X   ; Clear slot
         INX             ; Point to next
         CPX #$0090      ; Done 7 parties?
         BNE C37DAB      ; Loop if not
         JSR C37E7E      ; Compile members
         JSR C37FE7      ; Create members
         JMP C37E17      ; And candidates

; List and create actors in Lineup menu, define locked slots
C37DBE:  LDA #$FF        ; Actor: None
         LDX $00         ; Menu slot: 1
C37DC2:  STA $7E9D89,X   ; Clear slot
         INX             ; Point to next
         CPX #$00A0      ; Done party 7?
         BNE C37DC2      ; Loop if not
         LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDA $0201       ; Forced members?
         BMI C37DF9      ; Branch if not

; Fork: Compile candidates, etc.
C37DD7:  LDX $00         ; 1st: Terra
C37DD9:  LDA $1850,X     ; Party info
         AND #$40        ; Object's off?
         BEQ C37DEB      ; Skip if so
         LDA $1850,X     ; Party info
         AND #$07        ; In a party?
         BNE C37DEB      ; Skip if so
         TXA             ; Actor's slot
         STA $2180       ; Add to list
C37DEB:  INX             ; Actor slot +1
         CPX #$0010      ; Done all 16?
         BNE C37DD9      ; Loop if not
         LDA #$FF        ; Null value
         STA $2180       ; End list
         JMP C37E0B      ; Make/lock chars

; Fork: Clear assigned party for all actors
C37DF9:  LDX $00         ; 1st: Terra
C37DFB:  LDA $1850,X     ; Party info
         AND #$F8        ; Clear party
         STA $1850,X     ; Save changes
         INX             ; Actor slot +1
         CPX #$0010      ; Done all 16?
         BNE C37DFB      ; Loop if not
         BRA C37DD7      ; Create actors

; List members, create actors, and define locked slots in Lineup menu
C37E0B:  JSR C37E7E      ; Compile members
         JSR C37FE7      ; Create members
         JSR C37E17      ; And candidates
         JMP C380A0      ; Set locked slots

; Create all candidates in Lineup menu
C37E17:  LDX $00         ; Menu slot: 1
C37E19:  TDC             ; Clear A
         LDA $7E9D89,X   ; Actor in slot
         BMI C37E53      ; Skip if none
         PHX             ; Save slot
         PHA             ; Save actor
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         LDA #$02        ; Min slot: 16
         LDY #C381F3     ; C3/81F3
         JSR C311DE      ; Queue OAM fn
         TXY             ; Queue index
         TDC             ; Clear A
         PLA             ; Actor
         STA $7E35C9,X   ; Save for arrow
         JSR C3807F      ; Set anim ptr
         PLX             ; Menu slot
         LDA.L C37E5E,X  ; X position
         STA $33CA,Y     ; Set sprite's
         LDA.L C37E6E,X  ; Y position
         STA $344A,Y     ; Set sprite's
         TDC             ; Clear A
         STA $33CB,Y     ; No use...
         STA $344B,Y     ; No use...
         LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set ptr HB
C37E53:  INX             ; Menu slot +1
         CPX #$0010      ; Done top 16?
         BNE C37E19      ; Loop if not
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         RTS

; X positions for candidates in Lineup menu
C37E5E:  db $18          ; Slot 1
         db $34          ; Slot 2
         db $50          ; Slot 3
         db $6C          ; Slot 4
         db $88          ; Slot 5
         db $A4          ; Slot 6
         db $C0          ; Slot 7
         db $DC          ; Slot 8
         db $18          ; Slot 9
         db $34          ; Slot 10
         db $50          ; Slot 11
         db $6C          ; Slot 12
         db $88          ; Slot 13
         db $A4          ; Slot 14
         db $C0          ; Slot 15
         db $DC          ; Slot 16

; Y positions for candidates in Lineup menu
C37E6E:  db $5C          ; Slot 1
         db $5C          ; Slot 2
         db $5C          ; Slot 3
         db $5C          ; Slot 4
         db $5C          ; Slot 5
         db $5C          ; Slot 6
         db $5C          ; Slot 7
         db $5C          ; Slot 8
         db $78          ; Slot 9
         db $78          ; Slot 10
         db $78          ; Slot 11
         db $78          ; Slot 12
         db $78          ; Slot 13
         db $78          ; Slot 14
         db $78          ; Slot 15
         db $78          ; Slot 16

; List members by ID and choice, link each menu slot to a party
C37E7E:  LDX #$9DB9      ; 7E/9DB9
         STX $E7         ; Set WRAM LBs
         LDA $0201       ; Event data
         AND #$07        ; Group count
         STA $E6         ; Set counter
         LDA #$01        ; Party: 1st
         STA $E0         ; Set current
C37E8E:  LDX $E7         ; WRAM adr LBs
         STX $2181       ; Set register
         LDX $00         ; 1st: Terra
C37E95:  LDA $1850,X     ; Party info
         AND #$40        ; Object's off?
         BEQ C37EA9      ; Skip if so
         LDA $1850,X     ; Party info
         AND #$07        ; Isolate party
         CMP $E0         ; Matches ours?
         BNE C37EA9      ; Skip if not
         TXA             ; Actor slot
         STA $2180       ; Add to list
C37EA9:  INX             ; Actor slot +1
         CPX #$0010      ; Done all 16?
         BNE C37E95      ; Loop if not
         LDA #$FF        ; Null value
         STA $2180       ; End party list
         REP #$20        ; 16-bit A
         LDA $E7         ; WRAM adr LBs
         CLC             ; Prepare ADC
         ADC #$0010      ; To next party
         STA $E7         ; Save changes
         SEP #$20        ; 8-bit A
         INC $E0         ; Actual party +1
         DEC $E6         ; One less left
         BNE C37E8E      ; Loop till last
         JSR C37ECC      ; Sort by choice
         JMP C37F96      ; Mark all slots

; Sort members by player choice, merge into a unified list
C37ECC:  LDA $0201       ; Event data
         AND #$07        ; Group count
         STA $E6         ; Set counter
         LDX $00         ; 1st: Party 1
C37ED5:  LDA #$7E        ; Bank: 7E
         STA $E9         ; Set dest HB
         REP #$20        ; 16-bit A
         LDA.L C37F7A,X  ; Party RAM adr
         STA $E7         ; Set dest LBs
         LDA.L C37F7A+2,X; Source index
         PHX             ; Save dst index
         TAX             ; Index source
         SEP #$20        ; 8-bit A
         JSR C382AC      ; Sort party
         PLX             ; Dst index
         INX             ; Dst index +1
         INX             ; Dst index +1
         INX             ; Dst index +1
         INX             ; Dst index +1
         DEC $E6         ; One less group
         BNE C37ED5      ; Loop till last

; Fork: Merge sorted lists
C37EF5:  LDX #$9D99      ; 7E/9D99
         STX $2181       ; Set WRAM LBs
         LDA $0201       ; Group count
         AND #$7F        ; Clear flag
         CMP #$01        ; One group?
         BEQ C37F6A      ; Branch if so
         CMP #$02        ; Two groups?
         BEQ C37F57      ; Branch if so

; Fork: Add groups 1-3
C37F08:  JSR C37F57      ; Add groups 1+2
         LDX $00         ; Member slot: 1
C37F0D:  LDA $7E9DE1,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F0D      ; Loop if not

; Fork: Add group 4 (useless...)
C37F1A:  LDX $00         ; Member slot: 1
C37F1C:  LDA $7E9DF1,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F1C      ; Loop if not

; Fork: Add group 5 (useless...)
C37F29:  LDX $00         ; Member slot: 1
C37F2B:  LDA $7E9E01,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F2B      ; Loop if not

; Fork: Add group 6 (useless...)
C37F38:  LDX $00         ; Member slot: 1
C37F3A:  LDA $7E9E11,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F3A      ; Loop if not

; Fork: Add group 7 (useless...)
C37F47:  LDX $00         ; Member slot: 1
C37F49:  LDA $7E9E21,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F49      ; Loop if not
         RTS

; Fork: Add groups 1 and 2
C37F57:  JSR C37F6A      ; Add group 1
         LDX $00         ; Member slot: 1
C37F5C:  LDA $7E9DD1,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F5C      ; Loop if not
         RTS

; Fork: Add group 1
C37F6A:  LDX $00         ; Member slot: 1
C37F6C:  LDA $7E9DC1,X   ; Actor in slot
         STA $2180       ; Add to list
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 slots?
         BNE C37F6C      ; Loop if not
         RTS

; Source and destination for sorting a party (ID -> choice)
C37F7A:  dw $9DC1,$0030  ; P1: $9DB9 -> $9DC1
         dw $9DD1,$0040  ; P2: $9DC9 -> $9DD1
         dw $9DE1,$0050  ; P3: $9DD9 -> $9DE1
         dw $9DF1,$0060  ; P4: $9DE9 -> $9DF1 (unused)
         dw $9E01,$0070  ; P5: $9DF9 -> $9E01 (unused)
         dw $9E11,$0080  ; P6: $9E09 -> $9E11 (unused)
         dw $9E21,$0090  ; P7: $9E19 -> $9E21 (unused)

; Assign a party number to each slot in Lineup menu
C37F96:  LDX #$9E51      ; 7E/9E51
         STX $2181       ; Set WRAM LBs
         LDA #$10        ; Candidates: 16
C37F9E:  STZ $2180       ; Slot: No party
         DEC A           ; One less slot
         BNE C37F9E      ; Loop till last
         LDA $0201       ; Event data
         AND #$07        ; Group count
         CMP #$01        ; One group?
         BEQ C37FCD      ; Branch if so
         CMP #$02        ; Two groups?
         BEQ C37FD2      ; Branch if so
         JSR C37FD2      ; Do group 1+2
         LDA #$03        ; Group: 3
         JSR C37FDA      ; Mark 4 slots
         LDA #$04        ; Group: 4...
         JSR C37FDA      ; Mark 4 slots
         LDA #$05        ; Group: 5...
         JSR C37FDA      ; Mark 4 slots
         LDA #$06        ; Group: 6...
         JSR C37FDA      ; Mark 4 slots
         LDA #$07        ; Group: 7...
         JMP C37FDA      ; Mark 4 slots

; Fork: 1 group
C37FCD:  LDA #$01        ; Group: 1
         JMP C37FDA      ; Mark 4 slots

; Fork: 2 groups
C37FD2:  JSR C37FCD      ; Do group 1
         LDA #$02        ; Group: 2
         JMP C37FDA      ; ...
C37FDA:  STA $2180       ; Mark slot A
         STA $2180       ; Mark slot B
         STA $2180       ; Mark slot C
         STA $2180       ; Mark slot D
         RTS

; Create all party members in Lineup menu
C37FE7:  LDA $0201       ; Event data
         AND #$07        ; Group count
         STA $E6         ; Set counter
         LDX #$9DC1      ; 7E/9DC1
         STX $F3         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $F5         ; Set src HB
C37FF7:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C37FF7      ; Loop if not
         LDA $99         ; Always 0...
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$B0        ; 176
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDX $2134       ; Product LB
         STX $E4         ; Set base X

; Fork: Handle current party
C38013:  LDX $00         ; Member slot: 1
C38015:  TDC             ; Clear A
         TXY             ; Member slot
         LDA [$F3],Y     ; Actor in slot
         STA $F6         ; ...
         BMI C38054      ; Skip if nobody
         PHX             ; Save slot
         PHA             ; Save actor
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         LDA #$02        ; Min slot: 16
         LDY #C382C9     ; C3/82C9
         JSR C311DE      ; Queue OAM fn
         TXY             ; Queue index
         TDC             ; Clear A
         PLA             ; Actor in slot
         STA $7E35C9,X   ; Put in queue
         JSR C3807F      ; Set anim ptr
         PLX             ; Member slot
         TDC             ; Clear A
         LDA.L C38077,X  ; Relative X
         REP #$21        ; 16-bit A; C-
         ADC $E4         ; Add base X
         STA $33CA,Y     ; Set ally's X
         SEP #$20        ; 8-bit A
         LDA.L C3807B,X  ; Y position
         STA $344A,Y     ; Set ally's
         TDC             ; Clear A
         STA $344B,Y     ; No use...
         LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set ptr HB
C38054:  INX             ; Member slot +1
         CPX #$0004      ; Done all 4?
         BNE C38015      ; Loop if not

; Fork: Handle next party
C3805A:  REP #$20        ; 16-bit A
         LDA $F3         ; Party list adr
         CLC             ; Prepare ADC
         ADC #$0010      ; To next party
         STA $F3         ; Save changes
         LDA $E4         ; Base X pos
         CLC             ; Prepare ADC
         ADC #$0050      ; Go 80 px right
         STA $E4         ; Save changes
         SEP #$20        ; 8-bit A
         DEC $E6         ; One less group
         BNE C38013      ; Loop till last
         LDA #$00        ; Clear A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         RTS

; Relative X positions for party members in Lineup menu
C38077:  db $18          ; NW
         db $18          ; SW
         db $38          ; NE
         db $38          ; SE

; Y positions for party members in Lineup menu
C3807B:  db $9C          ; NW
         db $B8          ; SW
         db $9C          ; NE
         db $B8          ; SE

; Load pointer to actor's animation table
C3807F:  ASL A           ; Actor x2
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor address
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $0001,X     ; Sprite set
C3808E:  ASL A           ; Double it
         TAX             ; Index it
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $D8E9A1,X   ; Anim table ptr		=== SNES: $D8E917
         STA $32C9,Y     ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Establish locked actor slots in Lineup menu
C380A0:  LDX #$AC8D      ; 7E/AC8D
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         TAX             ; Menu slot: 1
C380A8:  PHX             ; Save menu slot
         TDC             ; Clear A
         LDA $7E9D89,X   ; Actor in slot
         BMI C380C7      ; Unlock if none
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C38396,X  ; Actor slot bit
         STA $E7         ; Memorize it
         LDA $0202       ; Forced actors
         AND $E7         ; Slot holds one?
         SEP #$20        ; 8-bit A
         BEQ C380C7      ; Unlock if not
         LDA #$FF        ; Slot: Locked
         BRA C380C8      ; Skip a line
C380C7:  TDC             ; Slot: Unlocked
C380C8:  STA $2180       ; Set slot status
         PLX             ; Current slot
         INX             ; Point to next
         CPX #$002C      ; Done all slots?
         BNE C380A8      ; Loop if not
         RTS

; Initialize and load portrait for Lineup menu
C380D3:  STZ $28         ; Portr slot: 1
         JSR C3826C      ; Init object
         LDA #$2F        ; Y: 47
         STA $7E344A,X   ; Set object's
         JSR C31517      ; Upload graphics
         JSR C383B6      ; Queue updating
         JMP C38435      ; Load palette

; Draw actor info in Lineup menu
C380E7:  JSR C38140      ; Erase BG1 text
         TDC             ; ...
         LDA $4B         ; Cursor slot
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if in party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot
         BMI C3813F      ; Exit if nobody
         STA $C9         ; Memorize it
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor's address
         STA $67         ; Memorize it
         SEP #$20        ; 8-bit A
         LDA #$24        ; Palette 1
         STA $29         ; Color: Blue
         LDX #C3815D     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3712C      ; Draw "LV/HP/MP"
         LDY #$3A1B      ; Class/KO pos			=== SNES: +40h as no diacritics
         LDX #$3048      ; Icon position
         LDA #$01        ; Anim mode: 1
         STA $48         ; Set for icons
         JSR C334C2      ; Do class/status		=== SNES: No class
         LDY #$3A9B      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDY #$3B1B      ; Text position		=== SNES: +40h as no diacritics
         JSR C335AE      ; Draw held esper
         LDY #C38172     ; Text pointer
         JSR C302F9      ; Draw HP's "/"
         LDY #C38176     ; Text pointer
         JSR C302F9      ; Draw MP's "/"
         LDX #C3817A     ; Coords tbl ptr
         JSR C30CD7      ; Draw LV, HP, MP
C3813F:  RTS

; Erase actor info on BG1 in Lineup menu
C38140:  LDX #$01C0      ; 7E/3A09
         REP #$20        ; 16-bit A
         TDC             ; Clear A
         LDA $00         ; ...
         LDY #$0060      ; Tiles: 192
C3814B:  STA $7E3849,X   ; Clear tile
         INX             ; Index +1
         INX             ; Index +1
         STA $7E3849,X   ; Clear tile
         INX             ; Index +1
         INX             ; Index +1
         DEY             ; 2 less tiles
         BNE C3814B      ; Loop till 0
         SEP #$20        ; 8-bit A
         RTS

; Text pointers for Lineup menu
C3815D:  dw C38163       ; LV
         dw C38168       ; HP
         dw C3816D       ; MP

; Positioned text for Lineup menu
C38163:  dw $3A6D : db "LV",$00
C38168:  dw $3AED : db "HP",$00
C3816D:  dw $3B6D : db "MP",$00
C38172:  dw $3AFB : db "/",$00
C38176:  dw $3B7B : db "/",$00

; Tilemap pointers for stats in Lineup menu
C3817A:  dw $3A77        ; LV
         dw $3AF3        ; HP
         dw $3AFD        ; Max HP
         dw $3B73        ; MP
         dw $3B7D        ; Max MP

; 67: Queue fade-out for Lineup menu
C38184:  JSR C330EA      ; Queue fade-out
         LDY #$0008      ; Frames: 8
         STY $20         ; Set fade timer
         LDA #$68        ; C3/81A2
         STA $26         ; Next: Wait
         JMP C37D4C      ; Update char info

; 66: Queue fade-in for Lineup menu
C38193:  JSR C330F1      ; Queue fade-in
         LDY #$0008      ; Frames: 8
         STY $20         ; Set fade timer
         LDA #$68        ; C3/81A2
         STA $26         ; Next: Wait
         JMP C37D4C      ; Update char info

; 68: Wait while Lineup menu fades in or out
C381A2:  LDY $20         ; Timer expired?
         BNE C381AA      ; Branch if not
         LDA $27         ; Queued command
         STA $26         ; Execute it next
C381AA:  JMP C37D4C      ; Update char info

; Update arrow for gear data menu
C381AD:  TAX             ; Index mode
         JMP (C381B1,X)  ; Handle mode

; Jump table for the above
C381B1:  dw C381B5       ; Initialize arrow
         dw C381D2       ; Sustain arrow

; Mode 0: Initialize arrow
C381B5:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #$ECF9      ; Anim table ptr		=== SNES: D8/EC6F
         STA $32C9,X     ; Set sprite's
         LDA #$0008      ; X: 8
         STA $33CA,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$D8        ; Bank: D8
         STA $35CA,X     ; Set ptr HB
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer

; Mode 1: Sustain arrow
C381D2:  LDY $2D         ; Queue index
         LDA $99         ; Arrow status
         BEQ C381DF      ; Hide if bogus
         BMI C381F1      ; Delete if off
         TDC             ; Clear A
         LDA #$02        ; Sprite: Normal
         BRA C381E0      ; Skip a line
C381DF:  TDC             ; Sprite: Blank
C381E0:  TAX             ; Index A
         REP #$20        ; 16-bit A
         LDA $D8ECF5,X   ; Anim table ptr		=== SNES: $D8EC6B
         STA $32C9,Y     ; Set sprite's
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C381F1:  CLC             ; Set to dequeue
         RTS

; Update Lineup or Colosseum candidate, or enemy Shadow
C381F3:  TAX             ; Index mode
         JMP (C381F7,X)  ; Handle mode

; Jump table for the above
C381F7:  dw C381FB       ; Initialize sprite
         dw C3820C       ; Sustain sprite

; Mode 0: Initialize sprite
C381FB:  LDA #$01        ; Hide actors: N
         TSB $47         ; Set menu flag
         LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$01        ; ...
         JSR C31271      ; Set pose timer
         JSR C38335      ; No arrow...

; Mode 1: Sustain sprite
C3820C:  LDA $47         ; Menu flags
         AND #$01        ; Remove actors?
         BEQ C38219      ; Delete if so
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C38219:  CLC             ; Set to dequeue
         RTS

; 69: Erase warning in Lineup menu after delay
C3821B:  LDA $20         ; Delay expired?
         BNE C38226      ; Branch if not
         LDA #$2D        ; C3/78FC
         STA $26         ; Next: Choice 1
         JSR C37CF6      ; Draw "Form..."
C38226:  JMP C37D4C      ; Update char info

; Positioned text for Lineup menu			=== SNES: +40h as no diacritics (all strings); "Lineup" is shifted left
C38229:  dw $38DD : db |パーティーを つ つくってください[end]|		; "Form   group(s).    "
C3823D:  dw $38CF : db |へんせい[end]|			; "Lineup"
C38244:  dw $38DD : db |パーティーのかずが つありません![end]|		; "You need   group(s)!"
C38258:  dw $38DD : db |だれもいません!         [end]|		; "No one there!       "

; Create portrait for Lineup menu
C3826C:  LDA #$03        ; Min slot: 24
         LDY #C30B7D     ; C3/0B7D
         JSR C311DE      ; Queue OAM fn
         TXA             ; Queue index
         STA $60         ; Set sprite's
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA #$001A      ; X: 26
         STA $33CA,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         TDC             ; ...
         LDA $28         ; Portrait slot
         JSR C38295      ; Load anim ptr
         TDC             ; Clear A
         STA $344B,X     ; No use...
         JSR C31271      ; Set pose timer
         PLB             ; Restore DB
         RTS

; Load animation table address for portrait
C38295:  PHX             ; Queue index
         PHX             ; Push again
         ASL A           ; Port slot x2
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C30B54,X  ; Anim table ptr
         PLY             ; Queue index
         STA $32C9,Y     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,Y     ; Set ptr HB
         PLX             ; Queue index
         RTS

; Sort members by actual order rather than actor slot
C382AC:  TDC             ; Clear A
         LDA $7E9D89,X   ; Actor slot
         STA $E1         ; Memorize it
         BMI C382C8      ; Exit if none
         PHX             ; List slot
         TAX             ; Actor slot
         LDA $1850,X     ; Party info
         AND #$18        ; Roster slot
         LSR A           ; Put in b2-b3
         LSR A           ; Put in b1-b2
         LSR A           ; Now 0-3
         TAY             ; Index it
         LDA $E1         ; Actor slot
         STA [$E7],Y     ; To new list
         PLX             ; List slot
         INX             ; List slot +1
         BRA C382AC      ; Do next slot
C382C8:  RTS

; Update conditional actor-related sprite
C382C9:  TAX             ; Index mode
         JMP (C382CD,X)  ; Handle mode

; Jump table for the above
C382CD:  dw C382D9       ; Initialize sprite V1
         dw C382ED       ; Initialize sprite V2
         dw C382F9       ; Initialize sprite V3
         dw C38305       ; Sustain sprite V1
         dw C38314       ; Sustain sprite V2
         dw C38328       ; Sustain sprite V3

; Mode 0: Init Lineup member, non-Lineup status icon, or arrow under actor; create arrow under forced member
C382D9:  LDA #$01        ; Ax like OBJs: N
         TSB $47         ; Set menu flag
         LDX $2D         ; Queue index
         LDA #$03        ; Mode: 3
         STA $3649,X     ; Set sprite's
         JSR C31271      ; Set pose timer
         TDC             ; Lineup member: Y
         JSR C38335      ; Add Lineup arrow
         BRA C38305      ; Define OAM

; Mode 1: Init Colosseum challenger or Lineup status icon
C382ED:  LDX $2D         ; Queue index
         LDA #$04        ; Mode: 4
         STA $3649,X     ; Set sprite's
         JSR C31271      ; Set pose timer
         BRA C38314      ; Define OAM

; Mode 2: Init unknown sprite (unused)
C382F9:  LDX $2D         ; Queue index
         LDA #$05        ; Mode: 5
         STA $3649,X     ; Set sprite's
         JSR C31271      ; Set pose timer
         BRA C38328      ; Define OAM

; Mode 3: Sustain Lineup member, non-Lineup status icon, or arrow under actor
C38305:  LDA $47         ; Menu flags
         AND #$01        ; Ax like objects?
         BEQ C38312      ; Delete if so
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C38312:  CLC             ; Set to dequeue
         RTS

; Mode 4: Sustain Colosseum challenger or Lineup status icon
C38314:  LDA $47         ; Menu flags
         AND #$02        ; Temp sprite?
         BEQ C38321      ; Branch if not
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         CLC             ; Set to dequeue
         RTS             ; Exit
C38321:  LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Mode 5: Sustain unknown sprite (unused)
C38328:  LDA $47         ; Menu flags
         AND #$04        ; Ax like objects?
         BEQ C38321      ; Branch if not
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         CLC             ; Set to dequeue
         RTS

; Create large arrow under actor if forced into party
C38335:  STA $E6         ; Save pose timer
         LDA $0200       ; Menu number
         CMP #$04        ; Lineup menu?
         BNE C38395      ; Exit if not
         LDX $2D         ; Queue index
         TDC             ; Clear A
         LDA $35C9,X     ; Actor in slot
         BMI C38395      ; Exit if arrow
         ASL A           ; Double it
         REP #$20        ; 16-bit A
         TAX             ; Index it
         LDA.L C38396,X  ; Actor slot bit
         STA $E7         ; Memorize it
         LDA $0202       ; Forced actors
         AND $E7         ; Includes ours?
         SEP #$20        ; 8-bit A
         BEQ C38395      ; Exit if not
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDA $E6         ; Party member?
         BNE C38366      ; Branch if not
         LDY #C382C9     ; C3/82C9
         BRA C38369      ; Skip a line
C38366:  LDY #C381F3     ; C3/81F3
C38369:  LDA #$03        ; Min slot: 24
         JSR C311DE      ; Queue OAM fn
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDA #$FF        ; Actor: None
         STA $35C9,X     ; For C3/8344
         LDY $374A,X     ; Actor's index
         REP #$20        ; 16-bit A
         LDA $33CA,Y     ; Actor's X
         STA $33CA,X     ; Set arrow's
         LDA $344A,Y     ; Actor's Y
         STA $344A,X     ; Set arrow's
         LDA #$EC33      ; Anim table ptr		=== SNES: D8/EBA9
         STA $32C9,X     ; Set arrow's
         SEP #$20        ; 8-bit A
         LDA #$D8        ; Bank: D8
         STA $35CA,X     ; Set ptr HB
C38395:  RTS

; Bitfield for actor slots
C38396:  dw $0001        ; Terra
         dw $0002        ; Locke
         dw $0004        ; Cyan
         dw $0008        ; Shadow
         dw $0010        ; Edgar
         dw $0020        ; Sabin
         dw $0040        ; Celes
         dw $0080        ; Strago
         dw $0100        ; Relm
         dw $0200        ; Setzer
         dw $0400        ; Mog
         dw $0800        ; Gau
         dw $1000        ; Gogo
         dw $2000        ; Umaro
         dw $4000        ; Guest 1
         dw $8000        ; Guest 2

; Set to upload portrait for Lineup menu
C383B6:  LDY #$2600      ; $2600
         STY $1B         ; Set VRAM ptr
         LDY #$0320      ; Bytes: 800
         STY $19         ; Set data size
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if on party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot
         BMI C3842B      ; Blank if none
         BRA C383F5      ; Set source

; Set to upload portrait A for Lineup group 5-8 (unused)
C383D1:  LDY #$2600      ; $2600
         STY $1B         ; Set VRAM ptr
         BRA C383E6      ; Set source

; Set to upload portrait B for Lineup group 5-8 (unused)
C383D8:  LDY #$2800      ; $2800
         STY $1B         ; Set VRAM ptr
         BRA C383E6      ; Set source

; Set to delete portrait B for Lineup group 5-8 (unused)
C383DF:  LDY #$2800      ; $2800
         STY $1B         ; Set VRAM ptr
         BRA C3842B      ; Set source

; Fork: Set source for portrait B (unused part)
C383E6:  LDY #$0320      ; Bytes: 800
         STY $19         ; Set data size
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9DA9,X   ; Actor in slot
         BMI C3842B      ; Blank if none
C383F5:  ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor address
         TAY             ; Index it
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $0014,Y     ; Status
         AND #$20        ; Imp?
         BEQ C3840C      ; Branch if not
         LDA #$0F        ; Use Imp image
         BRA C38416      ; Ignore actor
C3840C:  LDA $0000,Y     ; Actor
         CMP #$01        ; Locke?
         BEQ C38416      ; Branch if so
         LDA $0001,Y     ; Graphics set
C38416:  REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C376AF,X  ; GFX pointer
         CLC             ; ...
         ADC #$1D00      ; Add base adr
         STA $1D         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA #$ED        ; Bank: ED
         STA $1F         ; Set src HB
         RTS

; Fork: Point to blank portrait
C3842B:  LDY #$9F51      ; 7E/9F51
         STY $1D         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         RTS

; Load portrait palette for Lineup menu
C38435:  LDY $00         ; Palette: 0
         PHY             ; Save dest
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         CLC             ; Prepare ADC
         ADC $4A         ; +16 if on party
         ADC $5A         ; Always 0...
         TAX             ; Index sum
         LDA $7E9D89,X   ; Actor in slot
         BPL C3845D      ; Branch if any
         TDC             ; Use Terra
         BRA C3845D      ; Load palette

; Load portrait A's palette for Lineup group 5-8 (unused)
C3844A:  LDY $00         ; Palette: 0
         BRA C38451      ; Skip a line

; Load portrait B's palette for Lineup group 5-8 (unused part)
C3844E:  LDY #$0020      ; Palette: 1
C38451:  PHY             ; Save dest
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9DA9,X   ; Actor in slot
         BPL C3845D      ; Branch if any
         TDC             ; Use Terra
C3845D:  ASL A           ; Actor x2
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA #$10        ; Colors: 16
         STA $E3         ; Set counter
         LDA $0014,Y     ; Status
         AND #$20        ; Imp?
         BEQ C38478      ; Branch if not
         LDA #$0F        ; Use Imp data
         BRA C3847B      ; Skip a line
C38478:  LDA $0001,Y     ; Graphics set
C3847B:  TAX             ; Index it
         LDA.L C37694,X  ; Palette number
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         TAX             ; Index it
         PLY             ; RAM index
C38489:  REP #$20        ; 16-bit A
         PHX             ; Save ROM index
         LDA $ED5860,X   ; Portrait color
         TYX             ; RAM index
         STA $7E3149,X   ; To OBJ pal 0
         SEP #$20        ; 8-bit A
         PLX             ; ROM index
         INX             ; ROM index +1
         INX             ; ROM index +1
         INY             ; RAM index +1
         INY             ; RAM index +1
         DEC $E3         ; One less color
         BNE C38489      ; Loop till last
         SEP #$20        ; 8-bit A
         RTS

; Load navigation data for Item, Colosseum, or Sell menu
C384A3:  LDY #C384B2     ; C3/84B2
         JMP C30681      ; Load navig data

; Handle D-Pad for Item, Colosseum, or Sell menu
C384A9:  JSR C38948      ; Handle D-Pad
C384AC:  LDY #C384B7     ; C3/84B7
         JMP C306CB      ; Relocate cursor

; Navigation data for Item, Colosseum, and Sell menus
C384B2:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $02          ; 2 columns			=== SNES: 1
         db $0A          ; 10 rows

; Cursor positions for Item, Colosseum, and Sell menus
C384B7:  dw $5C08        ; Item 1
         dw $5C78        ; Item 2			=== SNES positions differ as single column
         dw $6808        ; Item 3
         dw $6878        ; Item 4
         dw $7408        ; Item 5
         dw $7478        ; Item 6
         dw $8008        ; Item 7
         dw $8078        ; Item 8
         dw $8C08        ; Item 9
         dw $8C78        ; Item 10
         dw $9808        ; Item 11			%%%
         dw $9878        ; Item 12
         dw $A408        ; Item 13
         dw $A478        ; Item 14
         dw $B008        ; Item 15
         dw $B078        ; Item 16
         dw $BC08        ; Item 17
         dw $BC78        ; Item 18
         dw $C808        ; Item 19
         dw $C878        ; Item 20

; Load navigation data for rare item menu
C384DF:  LDY #C384EE     ; C3/84EE
         JMP C30681      ; Load navig data

; Handle D-Pad for rare item menu
C384E5:  JSR C307B0      ; Handle D-Pad
C384E8:  LDY #C384F3     ; C3/84F3
         JMP C306C3      ; Relocate cursor

; Navigation data for rare item menu
C384EE:  db $00          ; Wraps on all sides
         db $00          ; Initial column
         db $00          ; Initial row
         db $03          ; 3 columns			=== SNES: 2
         db $0A          ; 10 rows

; Cursor positions for rare item menu
C384F3:  dw $5C08        ; Item 1
         dw $5C50        ; Item 2			=== SNES positions differ as 2 columns
         dw $5C98        ; Item 3
         dw $6808        ; Item 4
         dw $6850        ; Item 5
         dw $6898        ; Item 6
         dw $7408        ; Item 7
         dw $7450        ; Item 8
         dw $7498        ; Item 9
         dw $8008        ; Item 10
         dw $8050        ; Item 11
         dw $8098        ; Item 12
         dw $8C08        ; Item 13
         dw $8C50        ; Item 14
         dw $8C98        ; Item 15
         dw $9808        ; Item 16
         dw $9850        ; Item 17
         dw $9898        ; Item 18
         dw $A408        ; Item 19
         dw $A450        ; Item 20
         dw $A498        ; Item 21			%%%
         dw $B008        ; Item 22
         dw $B050        ; Item 23
         dw $B098        ; Item 24
         dw $BC08        ; Item 25
         dw $BC50        ; Item 26
         dw $BC98        ; Item 27
         dw $C808        ; Item 28
         dw $C850        ; Item 29
         dw $C898        ; Item 30

; Load navigation data for Item menu options
C3852F:  LDY #C38547     ; C3/8547
         JMP C30681      ; Load navig data

; Relocate cursor for Item menu options
C38535:  LDY #C3854C     ; C3/854C
         JMP C306C3      ; Relocate cursor

; Handle D-Pad for Item menu options
C3853B:  JSR C307B0      ; Handle D-Pad
         JSR C38535      ; Relocate cursor
         LDY $4D         ; Cursor position
         STY $0234       ; To cursor memory
         RTS

; Navigation data for Item menu options
C38547:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $03          ; 3 columns
         db $01          ; 1 row

; Cursor positions for Item menu options
C3854C:  dw $1640        ; USE
         dw $1670        ; ARRANGE			=== SNES: Shifted leftward
         dw $16A8        ; RARE				=== SNES: Shifted leftward

; Draw Item menu with inventory; upload element graphics
C38552:  LDA #$01        ; 64x32 at $0000
         STA $2107       ; Set BG1 map loc
         LDY #C385D2     ; C3/85D2
         JSR C303C4      ; Draw stats box A
         LDY #C385D6     ; C3/85D6
         JSR C303C4      ; Draw stats box B
         LDY #C385C6     ; C3/85C6
         JSR C303C4      ; Draw option box
         LDY #C385C2     ; C3/85C2
         JSR C303C4      ; Draw title box
         LDY #C385CA     ; C3/85CA
         JSR C303C4      ; Draw desc box
         LDY #C385CE     ; C3/85CE
         JSR C303C4      ; Draw main box
         JSR C30EBD      ; Upload windows
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         JSR C371DA      ; Clear BG3 map C
         JSR C371DF      ; Clear BG3 map D
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C394A0     ; Text pointer
         JSR C30326      ; Draw "Item"
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C3949A     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3714E      ; Draw options
         JSR C3B080      ; Build desc map
         JSR C3B319      ; Upload elements
         JSR C371AD      ; Clear BG1 map B
         JSR C385BC      ; Draw inventory
         JSR C38A72      ; Desc; item count
         JSR C30E93      ; Upload BG1 A+B
         JSR C30EA1      ; Upload BG1 B+C
         JSR C30ED9      ; Upload BG3 A+B
         JMP C30EE7      ; Upload BG3 C+D

; Draw inventory after clearing tilemap (Item, Colosseum, Sell)
C385BC:  JSR C371A9      ; Clear BG1 map A
         JMP C38737      ; Draw inventory

; Window layout for Item menu and gear data menu
C385C2:  dw $588B,$0204  ; 06x04 at $588B (Title)
C385C6:  dw $5897,$0216  ; 24x04 at $5897 (Options)
C385CA:  dw $598B,$031C  ; 30x05 at $598B (Description)
C385CE:  dw $5ACB,$0F1C  ; 30x17 at $5ACB (Main)
C385D2:  dw $60AD,$180D  ; 15x26 at $60AD (Gear stats; L part)
C385D6:  dw $5885,$1801  ; 03x26 at $5885 (Gear stats; R part)

; Set to condense text in Item, Colosseum, or Sell menu
C385DA:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set CH5 mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C38706     ; C3/8706
         STY $4352       ; Set CH5 src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set CH5 src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         JSR C38644      ; Load BG1 V-Data
         LDX $00         ; Index: 0
C385FD:  LDA.L C38689,X  ; BG1 H-Pan data
         STA $7E9A09,X   ; Save in RAM
         INX             ; Index +1
         CPX #$000D      ; End of table?
         BNE C385FD      ; Loop if not
         LDA #$02        ; 1Rx2B to PPU
         STA $4360       ; Set CH6 mode
         LDA #$0D        ; $210D
         STA $4361       ; To BG1 H-Scroll
         LDY #$9A09      ; 7E/9A09
         STY $4362       ; Set CH6 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4364       ; Set CH6 src HB
         LDA #$7E        ; ...
         STA $4367       ; Set indir HB
         LDA #$02        ; 1Rx2B to PPU
         STA $4370       ; Set CH7 mode
         LDA #$0E        ; $210E
         STA $4371       ; To BG1 V-Scroll
         LDY #$9849      ; 7E/9849
         STY $4372       ; Set CH7 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4374       ; Set CH7 src HB
         LDA #$7E        ; ...
         STA $4377       ; Set indir HB
         LDA #$C0        ; Channels: 6, 7
         TSB $43         ; Queue HDMA 6+7
         RTS

; Load BG1 vertical shift table for Item, Colosseum, or Sell menu
C38644:  LDX $00         ; Index: 0
C38646:  LDA.L C38696,X  ; Void's V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         CPX #$0012      ; At items?
         BNE C38646      ; Loop if not
C38654:  LDA.L C38696,X  ; Scanline data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         TDC             ; Clear A
         LDA $49         ; Top BG1 row
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         AND #$FF        ; ...
         REP #$20        ; 16-bit A
         CLC             ; Prepare ADC
         ADC.L C38696,X  ; Add V-Pan data
         STA $7E9849,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         INX             ; Index +1
         INX             ; Index +1
         CPX #$006C      ; Beyond items?
         BNE C38654      ; Loop if not
C3867A:  LDA.L C38696,X  ; Void's V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         CPX #$0070      ; End of table?
         BNE C3867A      ; Loop if not
         RTS

; BG1 H-Shift table for inventory-style menus
C38689:  db $28,$00,$01  ; Nothing
         db $2F,$00,$01  ; Nothing
         db $78,$00,$00  ; Items
         db $1E,$00,$01  ; Nothing
         db $00          ; End

; BG1 V-Shift table for inventory-style menus
C38696:  db $27,$80,$00  ; Nothing?
         db $08,$00,$00  ; Nothing?
         db $0C,$04,$00  ; Nothing?
         db $0C,$08,$00  ; Nothing?
         db $08,$80,$00  ; Nothing?
         db $08,$00,$00  ; Nothing?
         db $04,$AC,$FF  ; Item row 1
         db $04,$AC,$FF  ; Item row 2
         db $04,$AC,$FF  ; Item row 3
         db $04,$B0,$FF  ; Item row 4
         db $04,$B0,$FF  ; Item row 5
         db $04,$B0,$FF  ; Item row 6
         db $04,$B4,$FF  ; Item row 7
         db $04,$B4,$FF  ; Item row 8
         db $04,$B4,$FF  ; Item row 9
         db $04,$B8,$FF  ; Item row 10
         db $04,$B8,$FF  ; Item row 11
         db $04,$B8,$FF  ; Item row 12
         db $04,$BC,$FF  ; Item row 13
         db $04,$BC,$FF  ; Item row 14
         db $04,$BC,$FF  ; Item row 15
         db $04,$C0,$FF  ; Item row 16
         db $04,$C0,$FF  ; Item row 17
         db $04,$C0,$FF  ; Item row 18
         db $04,$C4,$FF  ; Item row 19
         db $04,$C4,$FF  ; Item row 20
         db $04,$C4,$FF  ; Item row 21
         db $04,$C8,$FF  ; Item row 22
         db $04,$C8,$FF  ; Item row 23
         db $04,$C8,$FF  ; Item row 24
         db $04,$CC,$FF  ; Item row 25
         db $04,$CC,$FF  ; Item row 26
         db $04,$CC,$FF  ; Item row 27
         db $04,$D0,$FF  ; Item row 28
         db $04,$D0,$FF  ; Item row 29
         db $04,$D0,$FF  ; Item row 30
         db $1E,$00,$00  ; Nothing
         db $00          ; End

; BG3 V-Shift table for Item and Colosseum menus
C38706:  db $2F,$00,$00  ; Title
         db $0C,$04,$00  ; Desc row 1
         db $0C,$08,$00  ; Desc row 2
         db $0C,$0C,$00  ; 2-hand
         db $0C,$10,$00  ; 50% Dmg
         db $0C,$14,$00  ; Vigor
         db $0C,$18,$00  ; Speed
         db $0C,$1C,$00  ; Stamina
         db $0C,$20,$00  ; Mag.Pwr
         db $0C,$24,$00  ; Bat.Pwr
         db $0C,$28,$00  ; Defense
         db $0C,$2C,$00  ; Evade
         db $0C,$30,$00  ; Mag.Def
         db $0C,$34,$00  ; MBlock
         db $0C,$38,$00  ; Nothing
         db $0C,$3C,$00  ; Nothing
         db $00          ; End

; Draw inventory for Item, Colosseum, or Sell menu
C38737:  JSR C38B78      ; Define $E5, $E6
         LDY #$000A      ; Rows left: 10
C3873D:  PHY             ; Save counter
         JSR C38752      ; Draw item row		=== SNES: One item per row
         INC $E5         ; Item slot +1
         INC $E5         ; Item slot +1			%%% SNES has 1 column
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C3873D      ; Loop till last
         RTS

; Draw a row of two items for Item, Colosseum, or Sell menu	=== SNES: One item, list item class
C38752:  TDC             ; Clear A
         LDA $E5         ; Item slot A
         TAY             ; Index it
         JSR C387C6      ; Choose palette
         LDA $1969,Y     ; Item quantity
         JSR C30563      ; Turn into text
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         LDX #$000D      ; X: 13			=== SNES: 17
         JSR C38820      ; Compute map ptr
         JSR C30539      ; Draw quantity
         LDA $E6         ; BG1 write row

         LDX #$0003      ; X: 3
         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Item slot
         TAY             ; Index it
         JSR C3883A      ; Load "<item>:"
         JSR C387B9      ; Draw item A

; Fork: Handle item B					%%%
C38786:  TDC             ; Clear A
         LDA $E5         ; Item slot A
         TAY             ; Index it
         INY             ; Now slot B
         JSR C387C6      ; Choose palette
         LDA $1969,Y     ; Item quantity
         JSR C30563      ; Turn into text
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         LDX #$001B      ; X: 27
         JSR C38820      ; Compute map ptr
         JSR C30539      ; Draw quantity
         LDA $E6         ; BG1 write row
         LDX #$0011      ; X: 17
         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Item slot A
         TAY             ; Index it
         INY             ; Now slot B
         JSR C3883A      ; Load "<item>:"		=== SNES ends with a JMP

; Draw memorized string with diacritics
C387B9:  LDY #$9E89      ; 7E/9E89
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JSR C3032C      ; Draw string
         RTS

















































; Choose item's color for Item, Colosseum, or Sell menu
C387C6:  LDA $0200       ; Root menu
         CMP #$03        ; Shop menu?
         BEQ C38806      ; Enable if so
         CMP #$07        ; Colosseum?
         BEQ C38806      ; Enable if so
         BRA C387D7      ; Handle main menu

; Fork: Get item slot (unused)
C387D3:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAY             ; Index it

; Fork: Main menu
C387D7:  LDA $1869,Y     ; Item in slot
         CMP #$EF        ; Megalixir?
         BEQ C3880B      ; Disable if so
         CMP #$FF        ; None?
         BEQ C38806      ; Enable if so
         CMP #$F7        ; Tent?
         BEQ C38810      ; Branch if so
         CMP #$F6        ; Sleeping Bag?
         BEQ C38810      ; Branch if so
         CMP #$FD        ; Warp Stone?
         BEQ C38817      ; Branch if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$06        ; Consumable?
         BNE C3880B      ; Disable if not
         LDA $D85000,X   ; Properties
         AND #$40        ; Usable in field?
         BEQ C3880B      ; Disable if not
C38806:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         RTS

; Fork: Set color to gray
C3880B:  LDA #$28        ; Palette 2
         STA $29         ; Color: Gray
         RTS

; Fork: Tent or Sleeping Bag
C38810:  LDA $0201       ; Can save here?
         BMI C38806      ; Enable if so
         BRA C3880B      ; Color: Gray

; Fork: Warp Stone
C38817:  LDA $0201       ; Area permissions
         BIT #$02        ; Can warp here?
         BNE C38806      ; Enable if so
         BRA C3880B      ; Color: Gray

; Compute position into BG1 tilemap A
C38820:  XBA             ; Switch to HB
         LDA $00         ; Clear it
         XBA             ; Y position
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         ASL A           ; x64
         STA $E7         ; Memorize it
         TXA             ; X position
         ASL A           ; Double it
         CLC             ; Prepare ADC
         ADC $E7         ; Add Y x64
         ADC #$3849      ; Add base adr
         TAX             ; Put sum in X
         SEP #$20        ; 8-bit A
         RTS

; Load owned item's name, add colon (Item, Colosseum, Sell)
C3883A:  LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
C38840:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C38840      ; Loop if not
         TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C38877      ; Blank if so
C3884F:  STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$09        ; Name data size		=== SNES: 13
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDX $2134       ; Index product
         LDY #$0009      ; Letters: 9			=== SNES: 13
C38863:  LDA $E6F700,X   ; Letter			=== SNES: $D2B300
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C38863      ; Loop till last
         LDA #$CF        ; Char: ":"			=== SNES: Different tile number
         STA $2180       ; Add to string
         STZ $2180       ; End string
         RTS

; Fork: Blank item name, colon, and quantity
C38877:  LDY #$000C      ; Spaces: 12			=== SNES: 16 (longer name)
         LDA #$FF        ; Space char
C3887C:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C3887C      ; Loop till last
         STZ $2180       ; End string
         RTS

; Adjust BG1 vertical shift amounts while list scrolls
C38886:  LDX #$0012      ; Scanline: 88th
C38889:  SEP #$20        ; 8-bit A
         LDA $7E9849,X   ; Scanline amount
         CMP #$1E        ; Last 30 lines?
         BEQ C388DF      ; Exit if so
         INX             ; RAM index +1
         PHX             ; Memorize it
         TDC             ; Clear A
         LDA $20         ; Scroll timer
         REP #$20        ; 16-bit A
         LDY $41         ; Scrolling up?
         BMI C388A0      ; Branch if so
         BRA C388A4      ; Skip 2 lines
C388A0:  CLC             ; Prepare ADC
         ADC #$0003      ; Timer +3
C388A4:  ASL A           ; Timer x2
         TAX             ; Index it
         TAY             ; Memorize it
         LDA.L C388E0,X  ; Shift mod; R1/3
         PLX             ; RAM index
         CLC             ; Prepare ADC
         ADC $7E9849,X   ; Add actual shift
         STA $7E9849,X   ; Set actual shift
         INX             ; RAM index +1
         INX             ; RAM index +1
         INX             ; RAM index +1
         PHX             ; Memorize it
         TYX             ; ROM index
         LDA.L C388EC,X  ; Shift mod; R2/3
         PLX             ; RAM index
         CLC             ; Prepare ADC
         ADC $7E9849,X   ; Add actual shift
         STA $7E9849,X   ; Set actual shift
         INX             ; RAM index +1
         INX             ; RAM index +1
         INX             ; RAM index +1
         PHX             ; Memorize it
         TYX             ; ROM index
         LDA.L C388F8,X  ; Shift mod; R3/3
         PLX             ; RAM index
         CLC             ; Prepare ADC
         ADC $7E9849,X   ; Add actual shift
         STA $7E9849,X   ; Set actual shift
         INX             ; RAM index +1
         INX             ; RAM index +1
         BRA C38889      ; Do next 12 lines
C388DF:  RTS

; Shift amount for 1st of every 3 rows of list scrolling down
C388E0:  dw $0008        ; Frame 3: +8 px down
         dw $0004        ; Frame 2: +4 px down
         dw $0004        ; Frame 1: +4 px down

; Shift amount for 1st of every 3 rows of list scrolling up
C388E6:  dw $FFFC        ; Frame 3: +4 px up
         dw $FFFC        ; Frame 2: +4 px up
         dw $FFF8        ; Frame 1: +8 px up

; Shift amount for 2nd of every 3 rows of list scrolling down
C388EC:  dw $0004        ; Frame 3: +4 px down
         dw $0008        ; Frame 2: +8 px down
         dw $0004        ; Frame 1: +4 px down

; Shift amount for 2nd of every 3 rows of list scrolling up
C388F2:  dw $FFFC        ; Frame 3: +4 px up
         dw $FFF8        ; Frame 2: +8 px up
         dw $FFFC        ; Frame 1: +4 px up

; Shift amount for every 3rd row of list scrolling down
C388F8:  dw $0004        ; Frame 3: +4 px down
         dw $0004        ; Frame 2: +4 px down
         dw $0008        ; Frame 1: +8 px down

; Shift amount for every 3rd row of list scrolling up
C388FE:  dw $FFF8        ; Frame 3: +8 px up
         dw $FFFC        ; Frame 2: +4 px up
         dw $FFFC        ; Frame 1: +4 px up

; Update scroll parameters for list
C38904:  TAX             ; Index mode
         JMP (C38908,X)  ; Handle mode

; Jump table for the above
C38908:  dw C38910       ; Scroll upward
         dw C3891D       ; Scroll downward
         dw C38928       ; Set timer
         dw C38931       ; Check timer

; Mode 0: Scroll upward
C38910:  LDX $2D         ; ...
         REP #$20        ; 16-bit A
         LDA #$FFFC      ; 4 px up
         STA $41         ; Set V-Speed
         SEP #$20        ; 8-bit A
         BRA C38928      ; Init timer

; Mode 1: Scroll downward
C3891D:  LDX $2D         ; ...
         REP #$20        ; 16-bit A
         LDA #$0004      ; 4 px down
         STA $41         ; Set V-Speed
         SEP #$20        ; 8-bit A

; Mode 2: Set timer
C38928:  LDX $2D         ; Queue index
         LDA #$03        ; Mode: 3
         STA $3649,X     ; Set next mode
         STA $20         ; Set timer

; Mode 3: Check timer
C38931:  LDX $2D         ; ...
         LDA $20         ; Timer expired?
         BEQ C3893D      ; Stop if so
         LDA #$20        ; Scroll BG1: Y
         TSB $46         ; Set menu flag
         SEC             ; Set to requeue
         RTS

; Fork: Stop scrolling
C3893D:  LDY $00         ; Clear Y
         STY $41         ; BG1 V-Speed: 0
         LDA #$20        ; Scroll BG1: N
         TRB $46         ; Set menu flag
         CLC             ; Set to dequeue
         RTS             ; ...
C38947:  RTS

; Handle D-Pad for scrollable list, change row when wrapping
C38948:  LDA $20         ; Scrolling now?
         BNE C38947      ; Exit if so

; Fork: Handle up
C3894C:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C3896B      ; Branch if not
         LDA $4E         ; On first row?
         BNE C38963      ; Go up if not
         LDA $4A         ; At top of list?
         BEQ C38947      ; Exit if so
         DEC $50         ; List row -1
         JSR C38A07      ; Queue scrolling
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Move cursor up
C38963:  DEC $50         ; List row -1
         DEC $4E         ; Cursor row -1
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Handle down
C3896B:  LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C38991      ; Branch if not
         LDA $54         ; Bottom menu row
         DEC A           ; Adjust value
         CMP $4E         ; Cursor's there?
         BNE C3898A      ; Go down if not
         LDA $4A         ; Scroll position
         CMP $5C         ; At very bottom?
         BEQ C38987      ; Exit if so
         INC $50         ; List row +1
         JSR C38A1F      ; Queue scrolling
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Exit
C38987:  JMP C38A06      ; RTS...

; Fork: Move cursor down
C3898A:  INC $50         ; List row +1
         INC $4E         ; Cursor row +1
         JSR C30F0E      ; Sound: Cursor

; Fork: Handle left
C38991:  LDA $0B         ; Semi-auto keys
         BIT #$02        ; Pushing left?
         BEQ C389CA      ; Branch if not
         LDA $4D         ; On first column?
         BNE C389C2      ; Branch if not
         LDA $4E         ; On top row?
         BEQ C389AE      ; Branch if so
         DEC $4E         ; Cursor row -1
         DEC $50         ; List row -1
         LDA $53         ; Furthest column
         DEC A           ; Adjust value
         STA $4D         ; Set as cursor's
         STA $4F         ; Set as list's
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Wrap to upper, offscreen row
C389AE:  LDA $4A         ; At top of list?
         BEQ C38947      ; Exit if so
         JSR C38A07      ; Queue scrolling
         LDA $53         ; Furthest column
         DEC A           ; Adjust value
         STA $4D         ; Set as cursor's
         STA $4F         ; Set as list's
         DEC $50         ; List row -1
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Move cursor left
C389C2:  DEC $4D         ; Cursor column -1
         DEC $4F         ; List column -1
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Handle right
C389CA:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C38A06      ; Exit if not
         LDA $53         ; Furthest column
         DEC A           ; Adjust value
         CMP $4D         ; Cursor's there?
         BNE C389FF      ; Go right if not
         LDA $54         ; Bottom menu row
         DEC A           ; Adjust value
         CMP $4E         ; Cursor's there?
         BEQ C389EB      ; Branch if so
         TDC             ; Clear A
         STA $4D         ; Cursor column: 1
         STA $4F         ; List column: 1
         INC $4E         ; Cursor row +1
         INC $50         ; List row +1
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Wrap to lower, offscreen row
C389EB:  LDA $4A         ; Scroll position
         CMP $5C         ; At very bottom?
         BEQ C38A06      ; Exit if so
         JSR C38A1F      ; Queue scrolling
         TDC             ; Clear A
         STA $4D         ; Cursor column: 1
         STA $4F         ; List column: 1
         INC $50         ; List row +1
         JSR C30F0E      ; Sound: Cursor
         RTS

; Fork: Move cursor right
C389FF:  INC $4D         ; Cursor column +1
         INC $4F         ; List column +1
         JSR C30F0E      ; Sound: Cursor
C38A06:  RTS

; Set to scroll list upward, draw row to scroll into view
C38A07:  DEC $4A         ; Scroll pos -1
         DEC $49         ; Top BG1 row -1
         JSR C38B78      ; Define $E5, $E6
         JSR C38A5E      ; Draw new row
         LDA #$00        ; Min slot: 0
         LDY #C38904     ; C3/8904
         JSR C311DE      ; Queue scroll fn
         TDC             ; Anim mode: Up
         STA $7E3649,X   ; Set scroll mode
         RTS

; Set to scroll list downward, draw row to scroll into view
C38A1F:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C38A1F      ; Loop if not
         LDA $5A         ; Rows per page
         CLC             ; Prepare ADC
         ADC $4A         ; Add scroll pos
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA $5B         ; Number of columns
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2134       ; Product LB
         STA $E5         ; Set SW list slot
         LDA $49         ; Top BG1 write row
         CLC             ; Prepare ADC
         ADC $5A         ; Get bottom row +1
         ASL A           ; x2 for blank rows
         AND #$1F        ; Stay in limits
         STA $E6         ; Set BG1 write row
         INC $4A         ; Scroll pos +1
         INC $49         ; Top BG1 row +1
         JSR C38A5E      ; Draw new row
         LDA #$00        ; Min slot: 0
         LDY #C38904     ; C3/8904
         JSR C311DE      ; Queue scroll fn
         LDA #$01        ; Anim mode: Down
         STA $7E3649,X   ; Set scroll mode
         RTS

; Draw list elements to scroll into view
C38A5E:  TDC             ; Clear A
         LDA $2A         ; List type
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C38A66,X)  ; Draw row

; Jump table for the above
C38A66:  dw C38752       ; Inventory
         dw C35670       ; Magic
         dw C35925       ; Lore
         dw C35A49       ; Rage
         dw C35B3D       ; Esper
         dw C3A4D1       ; Gear

; Load common item's description and draw item count in Item menu
C38A72:  JSR C38A89      ; Set desc ptrs
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAY             ; Index it
         LDA $1869,Y     ; Item in slot
         JSR C35D95      ; Load description
         JSR C38AD7      ; Count items
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JMP C38AFB      ; Draw item count

; Prepare item description loading
C38A89:  LDX #$6E00      ; D8/6E00			=== SNES: ED/7AA0
         STX $E7         ; Set ptr loc LBs
         LDX #$6400      ; ED/6400
         STX $EB         ; Set text loc LBs
         LDA #$D8        ; Bank: D8			=== SNES: ED
         STA $E9         ; Set ptr loc HB
         LDA #$ED        ; Bank: ED
         STA $ED         ; Set text loc HB
         LDX #$9EC9      ; 7E/9EC9
         STX $2181       ; Set WRAM LBs
         RTS

; Compute item data index
C38AA2:  PHA             ; Save item
C38AA3:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C38AA3      ; Loop if not
         PLA             ; Item
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$1E        ; Item data size
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         RTS

; Load rare item's description and draw item count
C38ABA:  LDX #$FB60      ; CE/FB60
         STX $E7         ; Set ptr loc LBs
         LDX #$FC90      ; CE/FC90			=== SNES: CE/FCB0
         STX $EB         ; Set text loc LBs
         LDA #$CE        ; Bank: CE
         STA $E9         ; Set ptr loc HB
         STA $ED         ; Set text loc HB
         JSR C35D87      ; Load description
         JSR C38AEC      ; Count items
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JMP C38AFB      ; Draw item count

; Count number of common items
C38AD7:  TDC             ; Clear A
         TAX             ; Item slot: 1
         TAY             ; Item count: 0
C38ADA:  LDA $1869,X     ; Item in slot
         CMP #$FF        ; None?
         BEQ C38AE2      ; Exclude if so
         INY             ; Item count +1
C38AE2:  INX             ; Item slot +1
         CPX #$0100      ; Done all 256?
         BNE C38ADA      ; Loop if not
         TYA             ; Get counter
         STA $64         ; Set item count
         RTS

; Count number of rare items
C38AEC:  TDC             ; Clear A
         TAX             ; Item slot: 1
C38AEE:  LDA $7E9D89,X   ; Empty slot?
         BMI C38AF7      ; Branch if so
         INX             ; Item slot +1
         BRA C38AEE      ; Check next slot
C38AF7:  TXA             ; Current slot
         STA $64         ; Set item count
         RTS

; Draw number of common or rare items
C38AFB:  LDA $64         ; Item count
         JSR C30563      ; Turn into text
         LDX #$7ABF      ; Text position
         JMP C30543      ; Draw 3 digits

; Blank item count in corner of Item menu
C38B06:  LDY #C395BF     ; Text pointer
         JMP C302F9      ; Draw 3 spaces

; Build and draw rare item list
C38B0C:  JSR C371A9      ; Clear BG1 map A
         JSR C38B15      ; Build item list
         JMP C38B5F      ; Draw item list

; Build rare item list
C38B15:  LDX #$9D89      ; 7E/9D89
         STX $2181       ; Set WRAM LBs
         LDY #$0021      ; Items: 33			=== SNES: 20 (notice 33 is more than needed, though a terminator is needed for counting rare items if all slots are filled)
         LDA #$FF        ; Empty item
C38B20:  STA $2180       ; Add to list
         DEY             ; One less left
         BNE C38B20      ; Loop till last
         LDX #$9D89      ; ...
         STX $2181       ; Reset WRAM LBs
         LDX $1EBA       ; Item packs A+B
         STX $EF         ; Memorize them
         LDA $1EBC       ; Item pack C
         STA $F1         ; Memorize it
         LDA $1EBD       ; Item pack D
         AND #$3F        ; Clear flags			=== SNES clears fewer flags
         STA $F2         ; Memorize it			=== SNES zeroes it (unused items)
         TDC             ; Item: Cider
         STA $E0         ; Set as current
         TAX             ; Pack index: 0
         LDA #$04        ; Item packs: 4
         STA $E1         ; Set counter
C38B45:  LDY #$0008      ; Items left: 8
         LDA $EF,X       ; 8 owned items
C38B4A:  ROR A           ; Got current?
         PHA             ; Save item pack
         BCC C38B53      ; Skip if not
         LDA $E0         ; Item number
         STA $2180       ; Add to list
C38B53:  INC $E0         ; Item number +1
         PLA             ; 8 owned items
         DEY             ; One less item
         BNE C38B4A      ; Loop till last
         INX             ; Pack index +1
         DEC $E1         ; One less pack
         BNE C38B45      ; Loop till last
         RTS

; Draw rare item list
C38B5F:  JSR C38B78      ; Define $E6
         STZ $E5         ; Item slot: 1
         LDY #$000A      ; Rows left: 10
C38B67:  PHY             ; Save counter
         JSR C38B9C      ; Draw 3 items			=== SNES: 2
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C38B67      ; Loop till last
         RTS

; Define BG1 row for drawing list, plus first onscreen list slot
C38B78:  LDA $49         ; Top BG1 write row
         ASL A           ; x2 for blank rows
         AND #$1F        ; Stay in limits
         STA $E6         ; Set BG1 write row
C38B7F:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C38B7F      ; Loop if not
         LDA $4A         ; Scroll position
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA $5B         ; Number of columns
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2134       ; Product LB
         STA $E5         ; Set list slot
         RTS

; Draw a row of three rare items			=== SNES: 2
C38B9C:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C38BC2      ; Define source
         LDX #$0003      ; X: 3
         JSR C38BD1      ; Draw item A
         INC $E5         ; Item slot +1
         JSR C38BC2      ; Define source
         LDX #$000C      ; X: 12			=== SNES: 17
         JSR C38BD1      ; Draw item B
         INC $E5         ; Item slot +1
         JSR C38BC2      ; Define source		%%%
         LDX #$0015      ; X: 21
         JSR C38BD1      ; Draw item C
         INC $E5         ; Item slot +1
         RTS

; Set source for loading rare item name
C38BC2:  LDY #$0008      ; Letters: 8			=== SNES: 13
         STY $EB         ; Set src size
         LDY #$FBA0      ; CE/FBA0
         STY $EF         ; Set src LBs
         LDA #$CE        ; Bank: CE
         STA $F1         ; Set src HB
         RTS

; Draw rare item name
C38BD1:  LDA $E6         ; BG1 write row

         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Item slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Item in slot
         CMP #$FF        ; None?
         BEQ C38BF1      ; Exit if so
         JSR C38BF2      ; Load name
         JMP C387B9      ; Draw name
C38BF1:  RTS

; Load fixed-size string from table
C38BF2:  PHA             ; Save name ID
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
C38BF9:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C38BF9      ; Loop if not
         PLA             ; Name number
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         TDC             ; Clear A
         LDA $EB         ; String size
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDY $2134       ; Index product
         LDX $EB         ; String size
C38C15:  LDA [$EF],Y     ; Letter
         STA $2180       ; Add to string
         INY             ; Point to next
         DEX             ; One less left
         BNE C38C15      ; Loop till last
         STZ $2180       ; End string
         RTS

; Handle double-clicked item
C38C22:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         STA $28         ; Set blinker's
         TAY             ; Index it
         LDA $1869,Y     ; Selected item
         CMP #$FF        ; Empty slot?
         BEQ C38C9B      ; Fail if so
         CMP #$EF        ; Megalixir?
         BEQ C38C9B      ; Fail if so...
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Item properties
         AND #$07        ; Get item type
         CMP #$06        ; Consumable?
         BNE C38CA0      ; Branch if not
         LDA $D85000,X   ; Item properties
         AND #$40        ; Usable in field?
         BEQ C38C9B      ; Fail if not
         TDC             ; ...
         LDA $28         ; Selected slot
         TAY             ; Index it
         LDA $1869,Y     ; Item in slot
         CMP #$F7        ; Tent?
         BEQ C38C83      ; Branch if so
         CMP #$F6        ; Sleeping Bag?
         BEQ C38C6D      ; Branch if so
         CMP #$FD        ; Warp Stone?
         BEQ C38C76      ; Branch if so
C38C5E:  LDY $4F         ; Cursor position
         STY $8E         ; Set return loc
         LDA $4A         ; Scroll position
         STA $90         ; Set return loc
         LDA #$6F        ; C3/920E
         STA $27         ; Queue usage menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Sleeping Bag
C38C6D:  STA $E6         ; Memorize item
         LDA $0201       ; Can save here?
         BPL C38C9B      ; Fail if not
         BRA C38C5E      ; Queue usage menu

; Fork: Warp Stone
C38C76:  STA $E6         ; Memorize item
         LDA $0201       ; Area permissions
         BIT #$02        ; Can warp here?
         BEQ C38C9B      ; Fail if not
         LDA #$03        ; Event: Warp
         BRA C38C8C      ; Destroy item

; Fork: Tent
C38C83:  STA $E6         ; Memorize item
         LDA $0201       ; Can save here?
         BPL C38C9B      ; Fail if not
         LDA #$02        ; Event: Tent
C38C8C:  STA $0205       ; Set aftereffect
         LDA $E6         ; Item
         JSR C3A5A5      ; Destroy it
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Unusable consumable
C38C9B:  LDA #$08        ; C3/1F5D
         STA $26         ; Next: Choice 1
         RTS

; Fork: Compile gear's compatible actors
C38CA0:  LDY #$9D89      ; 7E/9D89
         STY $2181       ; Set WRAM LBs
         CMP #$00        ; Tool class?
         BEQ C38C9B      ; Abort if so
         STZ $E0         ; Current: Terra
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         LDX $00         ; Actors done: 0
C38CB4:  LSR A           ; Actor can use?
         BCC C38CC2      ; Skip if not
         PHA             ; Save compat.
         SEP #$20        ; 8-bit A
         LDA $E0         ; Current actor
         STA $2180       ; Add to list
         REP #$20        ; 16-bit A
         PLA             ; Compatibility
C38CC2:  SEP #$20        ; 8-bit A
         INC $E0         ; Actor number +1
         REP #$20        ; 16-bit A
         INX             ; Actors done +1
         CPX #$000E      ; Done all 14?
         BNE C38CB4      ; Loop if not
         SEP #$20        ; 8-bit A
         LDA #$FF        ; Terminator
         STA $2180       ; End list

; Fork: Initialize gear data menu
C38CD5:  REP #$20        ; 16-bit A
         LDA #$00E0      ; BG1 H-Shift: 224
         STA $7E9A10     ; Hide item list
         LDA #$7D4F      ; Tilemap ptr			=== SNES: +40h as no diacritics; shifted leftward
         STA $7E9E89     ; Set item pos
         SEP #$20        ; 8-bit A
         LDA #$04        ; Cursor: Blank
         TRB $45         ; Set menu flag
         JSR C38D17      ; Stop desc/bar
         JSR C38D20      ; Create arrow
         TDC             ; ...
         LDA $4B         ; Item's slot
         TAY             ; Index it
         JSR C3883A      ; Load "<item>:"
         JSR C38D38      ; Add "can be..."
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         JSR C387B9      ; Draw string
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C38D60      ; Draw actor list
         JSR C38DFB      ; Draw other info
         JSR C30F90      ; Queue text upload
         JSR C30FF4      ; Dequeue desc DMA
         LDA #$64        ; C3/910D
         STA $26         ; Next: Sustain menu
         RTS

; Disable scrollbar and freeze description
C38D17:  LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         RTS

; Create arrow for gear data menu
C38D20:  LDA #$01        ; Status: On
         STA $99         ; Enable arrow
         LDA #$01        ; Min slot: 8
         LDY #C381AD     ; C3/81AD
         JSR C311DE      ; Queue OAM fn
         LDA #$80        ; Y: 128
         STA $7E344A,X   ; Set sprite's
         TDC             ; ...
         STA $7E344B,X   ; No use...
         RTS

; Add " can be used by:" after item name
C38D38:  LDX #$0001      ; Skip item icon
C38D3B:  LDA $7E9E8B,X   ; Item letter
         CMP #$FF        ; Terminator?
         BNE C38D58      ; Branch if not
C38D43:  LDY $00         ; ROM index: 0
C38D45:  PHX             ; Save RAM index
         TYX             ; ROM index
         LDA.L C394BD,X  ; Message letter
         PLX             ; RAM index
         STA $7E9E8B,X   ; Add to string
         INX             ; RAM index +1
         INY             ; ROM index +1
         CPY #$000F      ; Done 15 chars?		=== SNES: 17
         BNE C38D45      ; Loop if not
         RTS

; Fork: Check next letter from item name
C38D58:  INX             ; RAM index +1
         CPX #$0009      ; Done 8 chars?		=== SNES: 12
         BNE C38D3B      ; Loop if not
         BRA C38D43      ; Load "can..."

; Filter and draw gear's list of compatible actors
C38D60:  LDX #$9E09      ; 7E/9E09
         STX $2181       ; Set WRAM LBs
         LDX $00         ; List slot: 1
C38D68:  LDA $7E9D89,X   ; Eligible actor
         BMI C38DAE      ; Branch if end
         STA $E5         ; Memorize actor
         LDY $00         ; Actor slot: 1
         STY $E7         ; Save actor slot

; Fork: Exclude if never recruited or dead Shadow
C38D74:  STX $F3         ; Save list slot
         LDA $E5         ; Eligible actor
         CMP $1600,Y     ; In actor slot?
         BNE C38D95      ; Try next if not
         REP #$20        ; 16-bit A
         LDA $E7         ; Actor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $1EDC       ; Showable actors
         AND.L C3A456,X  ; Has our actor?
         SEP #$20        ; 8-bit A
         BEQ C38DA6      ; Skip if not
         LDA $E7         ; Actor slot
         STA $2180       ; Add to new list
         BRA C38DA6      ; Do next actor

; Fork: Try next actor in SRAM block
C38D95:  REP #$21        ; 16-bit A; C-
         TYA             ; Actor's address
         ADC #$0025      ; Point to next
         TAY             ; Reindex it
         SEP #$20        ; 8-bit A
         INC $E7         ; Actor slot +1
         LDA $E7         ; Actor slot
         CMP #$10        ; Done all 16?
         BNE C38D74      ; Loop if not

; Fork: Handle next eligible actor
C38DA6:  LDX $F3         ; List slot
         INX             ; List slot +1
         CPX #$0010      ; Done all 16?
         BNE C38D68      ; Loop if not

; Fork: End and draw new list
C38DAE:  LDA #$FF        ; Terminator
         STA $2180       ; End list
         TDC             ; Clear A			%%% SNES: LDX $00, TDC for loops (not needed in SFC version)
         TAX             ; List slot: 1
C38DB5:  LDA $7E9E09,X   ; Actor in slot
         BMI C38DDC      ; Exit if none
         PHX             ; Save slot
         PHX             ; Save slot
         REP #$20        ; 16-bit A
         ASL A           ; Actor x2
         TAX             ; Index it
         LDA.L C370DB,X  ; Actor address
         STA $67         ; Memorize it
         PLX             ; List slot
         TXA             ; Put in A
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C38DDD,X  ; Position
         TAY             ; Put in Y
         SEP #$20        ; 8-bit A
         JSR C3356A      ; Draw name
         PLX             ; List slot
         INX             ; List slot +1
         CPX #$000E      ; Done all 14?
         BNE C38DB5      ; Loop if not
C38DDC:  RTS

; Text positions for gear data menu
C38DDD:  dw $7DCF        ; Actor name 1			=== SNES: +40h as no diacritics (all names)
         dw $7DE3        ; Actor name 2
         dw $7DF7        ; Actor name 3
         dw $7E4F        ; Actor name 4
         dw $7E63        ; Actor name 5
         dw $7E77        ; Actor name 6
         dw $7ECF        ; Actor name 7
         dw $7EE3        ; Actor name 8
         dw $7EF7        ; Actor name 9
         dw $7F4F        ; Actor name 10
         dw $7F63        ; Actor name 11
         dw $7F77        ; Actor name 12
         dw $7FCF        ; Actor name 13
         dw $7FE3        ; Actor name 14
         dw $7FF7        ; Actor name 15 (unused)

; Draw all gear info except compatible actors
C38DFB:  JSR C371D5      ; Clear BG3 map B
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C394CC     ; Text ptrs loc
         LDY #$001C      ; Strings: 14
         JSR C3712C      ; Draw Vigor, etc.
         LDA #$2C        ; ...
         STA $29         ; ...
         LDX #C394E8     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3714E      ; Draw Speed, etc.

; Fork: Draw stat modifiers
C38E18:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         TDC             ; Clear A
         LDA $4B         ; Selected slot
         TAY             ; Index it
         LDA $1869,Y     ; Item in slot
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         TDC             ; Terminator
         STA $7E9E8D     ; Set mod B3
         STA $7E9E8E     ; Set mod B4
         REP #$20        ; 16-bit A
         LDA #$8445      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $D85010,X   ; Stat mods LB
         PHA             ; Memorize them
         AND #$0F        ; Vigor index
         ASL A           ; Double it
         JSR C38FC0      ; Draw modifier
         REP #$20        ; 16-bit A
         LDA #$84C5      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         PLA             ; Stat mods LB
         AND #$F0        ; Speed index
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         JSR C38FC0      ; Draw modifier
         REP #$20        ; 16-bit A
         LDA #$8545      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX $2134       ; Item index
         TDC             ; Clear A
         LDA $D85011,X   ; Stats mods HB
         PHA             ; Memorize them
         AND #$0F        ; Stamina index
         ASL A           ; Double it
         JSR C38FC0      ; Draw modifier
         REP #$20        ; 16-bit A
         LDA #$85C5      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         PLA             ; Stat mods HB
         AND #$F0        ; Mag.Pwr index
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         JSR C38FC0      ; Draw modifier

; Fork: Draw defensive properties
C38E8D:  LDX $2134       ; Item index
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$01        ; Weapon?
         BEQ C38ED0      ; Branch if so
         LDA $D85014,X   ; Defense
         JSR C30563      ; Turn into text
         LDX #$86C3      ; Text position
         JSR C30543      ; Draw 3 digits
         LDX $2134       ; Item index
         LDA $D85015,X   ; Mag.Def
         JSR C30563      ; Turn into text
         LDX #$87C3      ; Text position
         JSR C30543      ; Draw 3 digits
         JSR C38F75      ; Draw evasions
         JSR C3902A      ; Draw 50% elems
         JSR C390E3      ; Draw other ones
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C394F0     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3714E      ; Draw elem types
         JMP C38F51      ; Do spell taught

; Fork: Draw offensive properties
C38ED0:  JSR C38F26      ; Draw Bat.Pwr
         JSR C38F75      ; Draw evasions
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C3958A     ; Text pointer
         JSR C30326      ; Draw "Attack"
         JSR C3902A      ; Draw elements
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX $2134       ; Item index
         LDA $D85013,X   ; Allows Runic?
         BPL C38EF8      ; Branch if not
         LDY #C3959D     ; Text pointer
         STY $E7         ; Set src LBs
         JSR C38F1F      ; Draw "Runic"
C38EF8:  LDX $2134       ; Item index
         LDA $D85013,X   ; Properties
         AND #$40        ; 2-hand OK?
         BEQ C38F0B      ; Branch if not
         LDY #C395A9     ; Text pointer
         STY $E7         ; Set src LBs
         JSR C38F1F      ; Draw "2-hand"
C38F0B:  LDX $2134       ; Item index
         LDA $D85013,X   ; Properties
         AND #$02        ; Can SwdTech?
         BEQ C38F1E      ; Exit if not
         LDY #C39591     ; Text pointer
         STY $E7         ; Set src LBs
         JSR C38F1F      ; Draw "SwdTech"
C38F1E:  RTS

; Draw string for the above
C38F1F:  LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         JMP C302FF      ; Draw text

; Draw weapon's Bat.Pwr in gear data menu
C38F26:  TDC             ; Clear A
         LDA $4B         ; Clicked slot
         TAY             ; Index it
         LDA $1869,Y     ; Item in slot
         CMP #$1C        ; Atma Weapon?
         BEQ C38F4A      ; Hide if so
         CMP #$16        ; Soul Sabre?
         BEQ C38F4A      ; Hide if so
         CMP #$51        ; Dice?
         BEQ C38F4A      ; Hide if so
         CMP #$52        ; Fixed Dice?
         BEQ C38F4A      ; Hide if so
         LDA $D85014,X   ; Bat.Pwr
         JSR C30563      ; Turn into text
         LDX #$8643      ; Text position
         JMP C30543      ; Draw 3 digits

; Fork: Hide power
C38F4A:  LDY #C394F8     ; Text pointer
         JSR C302F9      ; Draw "???"
         RTS

; Draw spell taught by armor, including learning rate
C38F51:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX $2134       ; Item index
         LDA $D85003,X   ; Learning rate
         BEQ C38F74      ; Exit if 0
         STA $E0         ; Memorize it
         LDA $D85004,X   ; Spell taught
         STA $E1         ; Memorize it
         REP #$20        ; 16-bit A
         LDA #$82EF      ; Tilemap ptr			=== SNES: +40h as no diacritics
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         JSR C36142      ; Draw string
C38F74:  RTS

; Draw Evade and MBlock modifiers for gear data menu
C38F75:  REP #$20        ; 16-bit A
         LDA #$8743      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX $2134       ; Item index
         TDC             ; Clear A
         LDA $D8501A,X   ; Evasion mods
         PHA             ; Memorize them
         AND #$0F        ; Evade index
         ASL A           ; x2
         ASL A           ; x4
         JSR C38FA4      ; Draw modifier
         REP #$20        ; 16-bit A
         LDA #$8843      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX $2134       ; Item index
         TDC             ; Clear A
         PLA             ; Evasion mods
         AND #$F0        ; MBlock index
         LSR A           ; ÷2
         LSR A           ; ÷4
C38FA4:  TAX             ; Index it
         LDA.L C38FDE,X  ; Sign
         STA $7E9E8B     ; Add to string
         LDA.L C38FDE+1,X; Tens digit
         STA $7E9E8C     ; Add to string
         LDA.L C38FDE+2,X; Ones digit
         STA $7E9E8D     ; Add to string
         JMP C38FD1      ; Draw modifier

; Draw a non-evasion stat modifier for gear data menu
C38FC0:  TAX             ; Modifier index
         LDA.L C3900A,X  ; Sign
         STA $7E9E8B     ; Add to string
         LDA.L C3900A+1,X; Digit
         STA $7E9E8C     ; Add to string
C38FD1:  LDY #$9E89      ; 7E/9E89
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw modifier
         RTS

; Text for evasion modifiers
C38FDE:  db "  0",$00
         db "+10",$00
         db "+20",$00
         db "+30",$00
         db "+40",$00
         db "+50",$00
         db "-10",$00
         db "-20",$00
         db "-30",$00
         db "-40",$00
         db "-50",$00

; Text for non-evasion stat modifiers
C3900A:  db " 0"
         db "+1"
         db "+2"
         db "+3"
         db "+4"
         db "+5"
         db "+6"
         db "+7"
         db " 0"         ; Unused
         db "-1"
         db "-2"
         db "-3"
         db "-4"
         db "-5"
         db "-6"
         db "-7"

; Build and draw list of attack or halved elements
C3902A:  LDX $2134       ; Item index
         TDC             ; ...
         LDA $D8500F,X   ; Elements
         JSR C39038      ; Build list
         JMP C39058      ; Draw list

; Build current list of elements
C39038:  LDY #$AA8D      ; 7E/AA8D
         STY $2181       ; Set WRAM LBs
         STZ $E0         ; Current: Water
         LDY #$0008      ; Elements: 8
C39043:  ROL A           ; Draw current?
         BCC C3904D      ; Skip it if not
         PHA             ; Save elements
         LDA $E0         ; Current element
         STA $2180       ; Add to list
         PLA             ; Elements left
C3904D:  INC $E0         ; Elem number +1
         DEY             ; One less left
         BNE C39043      ; Loop till last
         LDA #$FF        ; Terminator
         STA $2180       ; End list
         RTS

; Draw list of attack or halved elements
C39058:  LDX #$7BCD      ; Tilemap ptr
         STX $EB         ; Set dest LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dest HB
         JMP C39088      ; Draw list

; Draw list of absorbed elements
C39064:  LDX #$7BE9      ; Tilemap ptr
         STX $EB         ; Set dest LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dest HB
         JMP C39088      ; Draw list

; Draw list of nulled elements
C39070:  LDX #$7CCD      ; Tilemap ptr
         STX $EB         ; Set dest LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dest HB
         JMP C39088      ; Draw list

; Draw list of elemental weaknesses
C3907C:  LDX #$7CE9      ; Tilemap ptr
         STX $EB         ; Set dest LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dest HB
         JMP C39088      ; ...

; Draw current list of elements
C39088:  TDC             ; Clear A
         TAX             ; Index: 0
C3908A:  TDC             ; Clear A
         LDA $7EAA8D,X   ; Element to draw
         BMI C390B0      ; Exit if no more
         PHX             ; Save list index
         REP #$20        ; 16-bit A
         ASL A           ; Element x2
         TAX             ; Index it
         LDA.L C390B1,X  ; Tilemap data
         STA $E0         ; Memorize it
         JSR C390C1      ; Draw element
         LDA $EB         ; Tilemap ptr
         CLC             ; ...
         ADC #$0004      ; Skip 2 tiles
         STA $EB         ; Save changes
         SEP #$20        ; 8-bit A
         PLX             ; List index
         INX             ; List index +1
         CPX #$0006      ; Done 6 entries?
         BNE C3908A      ; Loop if not
C390B0:  RTS

; Base tile attributes for each element
C390B1:  dw $3580        ; Water
         dw $3584        ; Earth
         dw $3588        ; Pearl
         dw $358C        ; Wind
         dw $3590        ; Poison
         dw $3594        ; Lightning
         dw $3598        ; Ice
         dw $359C        ; Fire

; Draw current element
C390C1:  TDC             ; Clear A
         TAY             ; Map ptr: NW
         LDA $E0         ; Attributes
         STA [$EB],Y     ; Set NW tile
         INC $E0         ; Tile num +1
         LDY #$0040      ; Map ptr: SW
         LDA $E0         ; Attributes
         STA [$EB],Y     ; Set SW tile
         INC $E0         ; Tile num +1
         LDY #$0002      ; Map ptr: NE
         LDA $E0         ; Attributes
         STA [$EB],Y     ; Set NE tile
         INC $E0         ; Tile num +1
         LDY #$0042      ; Map ptr: SE
         LDA $E0         ; Attributes
         STA [$EB],Y     ; Set SE tile
         RTS

; Build and draw list of absorbed, nulled, and weak elements
C390E3:  LDX $2134       ; Item index
         TDC             ; ...
         LDA $D85016,X   ; Absorbed elements
         JSR C39038      ; Build list
         JSR C39064      ; Draw list
         LDX $2134       ; Item index
         TDC             ; ...
         LDA $D85017,X   ; Nulled elements
         JSR C39038      ; Build list
         JSR C39070      ; Draw list
         LDX $2134       ; Item index
         TDC             ; ...
         LDA $D85018,X   ; Weak points
         JSR C39038      ; Build list
         JMP C3907C      ; Draw list

; 64: Sustain non-shifted gear data menu
C3910D:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BNE C39119      ; Branch if so
         LDA $09         ; No-autofire keys
         BIT #$02        ; Pushing left?
         BEQ C39132      ; Branch if not
C39119:  JSR C30F1D      ; Sound: Click
         LDA #$FF        ; Status: Off
         STA $99         ; Disable arrow
         LDA #$0A        ; Frames: 10
         STA $20         ; Set scroll timer
         LDY #$FFF4      ; Speed: -12
         STY $9C         ; Set scroll speed
         LDA #$5E        ; C3/9170
         STA $27         ; Queue: Moved menu
         LDA #$65        ; C3/37AF
         STA $26         ; Next: Pan screen
         RTS

; Fork: Handle B
C39132:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C39167      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA #$FF        ; Status: Off
         STA $99         ; Disable arrow
         LDX #$7B49      ; 7E/7B49
         STX $2181       ; Set WRAM LBs
         LDX #$0280      ; BG3 tiles: 640
C39148:  STZ $2180       ; Clear tile LB
         STZ $2180       ; Clear tile HB
         DEX             ; One less tile
         BNE C39148      ; Loop till last
         LDA #$04        ; Show cursor: Y
         TSB $45         ; Set menu flag
         JSR C39168      ; Desc/Bar: On
         JSR C30FA4      ; Queue BG3 upload
         JSR C313D3      ; Upload it now
         TDC             ; BG1 H-Shift: 0
         STA $7E9A10     ; Unhide item list
         LDA #$08        ; C3/1F5D
         STA $26         ; Next: Choice 1
C39167:  RTS

; Create scrollbar and set to update description
C39168:  JSR C309A4      ; Create scrollbar
         LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         RTS

; 5E: Sustain shifted gear data menu
C39170:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BNE C3917C      ; Branch if so
         LDA $09         ; ...
         BIT #$01        ; Pushing right?
         BEQ C39197      ; Exit if not
C3917C:  JSR C30F14      ; Sound: Cursor
         LDA #$0A        ; Frames: 10
         STA $20         ; Set scroll timer
         LDY #$000C      ; Speed: 12
         STY $9C         ; Set scroll speed
         LDA #$05        ; Blinker: Off...
         TRB $46         ; Set menu flag
         LDA #$64        ; C3/910D
         STA $27         ; Queue screen 1
         LDA #$65        ; C3/37AF
         STA $26         ; Next: Pan screen
         JSR C38D20      ; Create arrow
C39197:  RTS

; Draw item usage menu
C39198:  JSR C371BC      ; Clear BG2 map A
         LDY #C391C5     ; C3/91C5
         JSR C303C4      ; Draw party box
         LDY #C391C9     ; C3/91C9
         JSR C303C4      ; Draw item box
         LDY #C391CD     ; C3/91CD
         JSR C303C4      ; Draw quantity box
         JSR C30EBD      ; Upload windows
         JSR C371AD      ; Clear BG1 map B
         LDY #$FFC0      ; X: -64 = 448
         STY $35         ; Set BG1 X-Pos
         LDA #$02        ; Portrait row bit
         TSB $45         ; Ignore back row
         JSR C33225      ; Draw party info
         JSR C391D1      ; Draw item info
         JMP C3323A      ; Upload text maps

; Window layout for item usage menu
C391C5:  dw $589D,$1813  ; 21x26 at $589D (Party)
C391C9:  dw $588B,$0208  ; 10x04 at $588B (Item)	=== SNES: Expanded rightward
C391CD:  dw $598B,$0307  ; 09x05 at $598B (Quantity)

; Draw item info for item usage menu
C391D1:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C395B5     ; Text pointer
         JSR C30326      ; Draw "Owned:"
         REP #$20        ; 16-bit A
         LDA #$78CB      ; Tilemap ptr			=== SNES: +40h as no diacritics
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $4B         ; Item's slot
         TAY             ; Index it
         JSR C3883A      ; Load "<item>:"
         TDC             ; Terminator
         STA $7E9E94     ; Remove ":"			=== SNES: $7E9E98 (longer item names)
         JSR C387B9      ; Draw item
         BRA C391F7      ; ...

; Draw quantity owned for item usage menu
C391F7:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         TDC             ; Clear A
         LDA $28         ; Item's slot
         TAY             ; Index it
         LDA $1969,Y     ; Item quantity
         JSR C30563      ; Turn into text
         LDX #$7A93      ; Text position
         JSR C30539      ; Draw 2 digits
         JMP C387B9      ; Redraw item...

; 6F: Initialize item usage menu
C3920E:  JSR C32B11      ; Init variables
         JSR C39198      ; Draw menu
         JSR C30833      ; Queue cursor OAM
         LDA #$40        ; No cursor memory
         TSB $45         ; Set menu flag
         LDA #$70        ; Queue: Sustain menu
         JMP C32B40      ; Next: Fade-in

; 70: Sustain item usage menu
C39220:  JSR C30F68      ; Queue stats upload
         JSR C30FCC      ; And item info's
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C39236      ; Branch if not
         JSR C393B5      ; Item
         CMP #$E7        ; Rename Card?
         BEQ C3924A      ; Branch if so
         JSR C39271      ; Handle item usage

; Fork: Handle B
C39236:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C39249      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C3923F:  LDA #$42        ; Allow back row
         TRB $45         ; And cursor memory
         LDA #$77        ; C3/1B9B
         STA $27         ; Queue Item menu
         STZ $26         ; Next: Fade-out
C39249:  RTS

; Fork: Rename Card
C3924A:  JSR C32DA6      ; Define Y
         LDA $0000,Y     ; Actor
         CMP #$0E        ; Guest?
         BCS C3926A      ; Fail if so
         STY $0206       ; Save actor adr
         JSR C30F1D      ; Sound: Click
         LDA #$FE        ; Actor renaming
         STA $0205       ; Set next menu
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         LDA #$E7        ; Item number
         JMP C3A5A5      ; Destroy item

; Fork: Prevent guest renaming
C3926A:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Handle item usage, excluding Rename Card
C39271:  JSR C393B5      ; ...
         JSR C32DA6      ; Target's address
         JSR C392C7      ; Valid target?
         BCC C39294      ; Fail if not
         JSR C30F50      ; Play heal sound
         JSR C3929B      ; Heal & destroy
         JSR C391F7      ; Redraw quantity
         JSR C32C9C      ; Redraw party
         TDC             ; Clear A
         LDA $28         ; Item's slot
         TAY             ; Index it
         LDA $1969,Y     ; Item quantity
         BNE C3929A      ; Exit if not 0
         JMP C3923F      ; Close submenu
C39294:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
C3929A:  RTS

; Heal item's target, destroy item
C3929B:  JSR C392A4      ; Heal target
         JSR C393B5      ; Selected item
         JMP C3A5A5      ; Destroy item

; Adjust item target's HP, MP, and status
C392A4:  LDA $0014,Y     ; Status LB
         STA $F8         ; Set target's
         LDA $0015,Y     ; Status HB
         STA $FB         ; Set target's
         PHY             ; Save index
         JSR C393B5      ; Item number
         LDX #$0002      ; Mode: Item
         JSL $C20009     ; Get new status
         PLY             ; Actor's address
         LDA $FC         ; Status LB
         STA $0014,Y     ; Set actor's
         LDA $FF         ; Status HB
         STA $0015,Y     ; Set actor's
         JMP C393BD      ; Heal HP & MP

; Determine whether item target is valid
C392C7:  LDA $0014,Y     ; Status
         AND #$80        ; Wound?
         BNE C3930F      ; Branch if so
         JSR C393B5      ; Item
         CMP #$FE        ; Dried Meat?
         BEQ C3934E      ; Branch if so
         CMP #$E8        ; Tonic?
         BEQ C3934E      ; Branch if so
         CMP #$E9        ; Potion?
         BEQ C3934E      ; Branch if so
         CMP #$EA        ; X-Potion?
         BEQ C3934E      ; Branch if so
         CMP #$EB        ; Tincture?
         BEQ C3935F      ; Branch if so
         CMP #$EC        ; Ether?
         BEQ C3935F      ; Branch if so
         CMP #$ED        ; X-Ether?
         BEQ C3935F      ; Branch if so
         CMP #$F1        ; Revivify?
         BEQ C39318      ; Branch if so
         CMP #$F2        ; Antidote?
         BEQ C39345      ; Branch if so
         CMP #$F3        ; Eyedrop?
         BEQ C39321      ; Branch if so
         CMP #$F4        ; Soft?
         BEQ C3932A      ; Branch if so
         CMP #$F5        ; Remedy?
         BEQ C3933C      ; Branch if so
         CMP #$EE        ; Elixir?
         BEQ C3936F      ; Branch if so
         CMP #$F8        ; Green Cherry?
         BEQ C39333      ; Branch if so
         CMP #$F6        ; Sleeping Bag?
         BEQ C3935C      ; Branch if so
         BRA C3935A      ; Make item fail

; Fork: Fenix Down
C3930F:  JSR C393B5      ; Item
         CMP #$F0        ; Fenix Down?
         BEQ C3936D      ; Succeed if so
         BRA C3935A      ; Make item fail

; Fork: Revivify
C39318:  LDA $0014,Y     ; Status
         AND #$02        ; Zombie?
         BEQ C3935A      ; Fail if not
         BRA C3936D      ; Make item work

; Fork: Eyedrop
C39321:  LDA $0014,Y     ; Status
         AND #$01        ; Dark?
         BEQ C3935A      ; Fail if not
         BRA C3936D      ; Make item work

; Fork: Soft
C3932A:  LDA $0014,Y     ; Status
         AND #$40        ; Petrify?
         BEQ C3935A      ; Fail if not
         BRA C3936D      ; Make item work

; Fork: Green Cherry
C39333:  LDA $0014,Y     ; Status
         AND #$20        ; Imp?
         BEQ C3935A      ; Fail if not
         BRA C3936D      ; Make item work

; Fork: Remedy
C3933C:  LDA $0014,Y     ; Dark? Poison?
         AND #$65        ; Imp? Petrify?
         BEQ C3935A      ; Fail if none
         BRA C3936D      ; Make item work

; Fork: Antidote
C39345:  LDA $0014,Y     ; Status
         AND #$04        ; Poison?
         BEQ C3935A      ; Fail if not
         BRA C3936D      ; Make item work

; Fork: Dried Meat, Tonic, Potion, X-Potion
C3934E:  LDA $0014,Y     ; Zombie? KO?
         AND #$C2        ; Or Petrify?
         BNE C3935A      ; Fail if any
         JSR C32C35      ; At full HP?
         BCC C3936D      ; Succeed if not

; Fork: Make item fail
C3935A:  CLC             ; Mark failure
         RTS

; Fork: Sleeping Bag (A)
C3935C:  JMP C3939B      ; BRA...

; Fork: Tincture, Ether, X-Ether
C3935F:  LDA $0014,Y     ; Zombie? KO?
         AND #$C2        ; Or Petrify?
         BNE C3935A      ; Fail if any
         JSR C32C57      ; At full MP?
         BCC C3936D      ; Succeed if not
         BRA C3935A      ; Make item fail

; Fork: Make item work
C3936D:  SEC             ; Mark success
         RTS

; Fork: Elixir
C3936F:  LDA $0014,Y     ; Zombie? KO?
         AND #$C2        ; Or Petrify?
         BNE C3935A      ; Fail if any
         JSR C32C35      ; At full HP?
         BCC C3936D      ; Succeed if not
         JSR C32C57      ; At full MP?
         BCC C3936D      ; Succeed if not
         BRA C3935A      ; Make item fail

; Fork: Megalixir (unused)
C39382:  TDC             ; Clear A
         TAX             ; Member index: 0
C39384:  STX $ED         ; Memorize index
         LDY $006D,X     ; Actor's address
         BEQ C39390      ; Skip if nobody
         JSR C3936F      ; Run Elixir test
         BCS C3936D      ; Heal if passed
C39390:  LDX $ED         ; Member index
         INX             ; Member index +1
         INX             ; Member index +1
         CPX #$0008      ; Done 4 members?
         BNE C39384      ; Loop if not
         BRA C3935A      ; Make item fail

; Fork: Sleeping Bag (B)
C3939B:  LDA $0014,Y     ; Dark/Zom/Pois?
         AND #$F7        ; Clear/Imp/Pet/KO?
         BNE C3936D      ; Succeed if any
         LDA $0015,Y     ; Status HB
         AND #$80        ; Float?
         BNE C3936D      ; Succeed if so
         JSR C32C35      ; At full HP?
         BCC C3936D      ; Succeed if not
         JSR C32C57      ; At full MP?
         BCC C3936D      ; Succeed if not
         BRA C3935A      ; Make item fail

; Get selected recovery item
C393B5:  TDC             ; Clear A
         LDA $28         ; Inventory slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         RTS

; Handle HP and MP recovery from item
C393BD:  PHY             ; ...
         JSR C393B5      ; Item
         JSR C38AA2      ; Compute index
         PLY             ; ...
         LDX $2134       ; Load it
         STX $B0         ; Memorize it
         JSR C39457      ; Load item power
         LDA $D85013,X   ; Fixed healing?
         BMI C39400      ; Branch if not
         AND #$08        ; Affects HP?
         BEQ C393E6      ; Branch if not

; Fork: Fixed HP healing
C393D7:  REP #$21        ; 16-bit A; C-
         LDA $B2         ; Item's power
         ADC $0009,Y     ; Add target's HP
         STA $0009,Y     ; Set target's HP
         SEP #$20        ; 8-bit A
         JSR C32C35      ; Enforce max HP

; Fork: Fixed MP healing
C393E6:  LDX $B0         ; Item index
         LDA $D85013,X   ; Properties
         AND #$10        ; Affects MP?
         BEQ C393FF      ; Exit if not
         REP #$21        ; 16-bit A; C-
         LDA $B2         ; Item's power
         ADC $000D,Y     ; Add target's MP
         STA $000D,Y     ; Set target's MP
         SEP #$20        ; 8-bit A
         JSR C32C57      ; Enforce max MP
C393FF:  RTS

; Fork: Fractional HP healing
C39400:  LDA $D85013,X   ; Properties
         AND #$08        ; Affects HP?
         BEQ C3942A      ; Branch if not
         LDA $000B,Y     ; Max HP LB
         STA $F3         ; Memorize it
         LDA $000C,Y     ; Max HP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30DFD      ; Cap at 9999
         JSR C39460      ; Max HP x Pwr/16
         REP #$21        ; 16-bit A; C-
         LDA $E9         ; Product
         ADC $0009,Y     ; Add target's HP
         STA $0009,Y     ; Set target's HP
         SEP #$20        ; 8-bit A
         JSR C32C35      ; Enforce max HP

; Fork: Fractional MP healing
C3942A:  LDX $B0         ; Item index
         LDA $D85013,X   ; Properties
         AND #$10        ; Affects MP?
         BEQ C39456      ; Exit if not
         LDA $000F,Y     ; Max MP LB
         STA $F3         ; Memorize it
         LDA $0010,Y     ; Max MP HB
         STA $F4         ; Memorize it
         JSR C30DD0      ; Add gear bonus
         JSR C30E0A      ; Cap at 999
         JSR C39460      ; Max MP x Pwr/16
         REP #$21        ; 16-bit A; C-
         LDA $E9         ; Product
         ADC $000D,Y     ; Add target's MP
         STA $000D,Y     ; Set target's MP
         SEP #$20        ; 8-bit A
         JSR C32C57      ; Enforce max MP
C39456:  RTS

; Load recovery item's power
C39457:  LDA $D85014,X   ; Item's power
         STA $B2         ; Memorize it
         STZ $B3         ; Clear HB
         RTS

; Multiply max HP or MP by item's power, divide by 16
C39460:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C39460      ; Loop if not
         LDA $F3         ; Max HP/MP LB
         STA $211B       ; Set matrix A LB
         LDA $F4         ; Max HP/MP HB
         STA $211B       ; Set matrix A HB
         LDA $B2         ; Item's power
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDA $2136       ; Product HB
         STA $EB         ; Set gain B3
         STZ $EC         ; Clear byte 4
         REP #$20        ; 16-bit A
         LDA $2134       ; Product LBs
         STA $E9         ; Set gain LBs
         LSR $EB         ; Halve HBs
         ROR $E9         ; Halve LBs w/ C
         LSR $EB         ; Halve HBs
         ROR $E9         ; Halve LBs w/ C
         LSR $EB         ; Halve HBs
         ROR $E9         ; Halve LBs w/ C
         LSR $EB         ; Halve HBs
         ROR $E9         ; Halve LBs w/ C
         SEP #$20        ; 8-bit A
         RTS

; Text pointers for Item menu
C3949A:  dw C394A7       ; USE
         dw C394AD       ; ARRANGE
         dw C394B4       ; RARE

; Positioned text for Item menu
C394A0:  dw $78CD : db |アイテム[end]|	; Item		=== SNES: +40h as no diacritics (all 4 strings)
C394A7:  dw $78DD : db |つかう[end]|	; USE
C394AD:  dw $78E9 : db |せいとん[end]|	; ARRANGE	=== SNES: Shifted leftward
C394B4:  dw $78F7 : db |だいじなもの[end]|	; RARE		=== SNES: Shifted rightward

; Text for gear data menu, " can be used by:"
C394BD:  db |を そうびできるキャラクター[end]|

; Text pointers for gear data menu
C394CC:  dw C394FE       ; Vigor
         dw C39504       ; Stamina
         dw C3950C       ; Mag.Pwr
         dw C39513       ; Evade %
         dw C3951B       ; MBlock%
         dw C39526       ; ‥
         dw C3952A       ; ‥
         dw C3952E       ; ‥
         dw C39532       ; ‥
         dw C39536       ; ‥
         dw C3953A       ; ‥
         dw C3953E       ; ‥
         dw C39542       ; ‥
         dw C39546       ; ‥
C394E8:  dw C3954A       ; Speed
         dw C39551       ; Bat.Pwr
         dw C3955B       ; Defense
         dw C39562       ; Mag.Def
C394F0:  dw C3956C       ; 50% Dmg
         dw C39573       ; Absorb HP
         dw C3957C       ; No Effect
         dw C39582       ; Weak pt

; Positioned text for gear data menu
C394F8:  dw $8643 : db "???",$00
C394FE:  dw $842F : db |ちから[end]|		; Vigor
C39504:  dw $852F : db |たいりょく[end]|		; Stamina
C3950C:  dw $85AF : db |まりょく[end]|		; Mag.Pwr
C39513:  dw $872F : db |かいひりつ[end]|		; Evade %
C3951B:  dw $882F : db |まほうかいひりつ[end]|		; MBlock%
C39526:  dw $843F : db |‥[end]|
C3952A:  dw $84BF : db |‥[end]|
C3952E:  dw $853F : db |‥[end]|
C39532:  dw $85BF : db |‥[end]|
C39536:  dw $863F : db |‥[end]|
C3953A:  dw $86BF : db |‥[end]|
C3953E:  dw $873F : db |‥[end]|
C39542:  dw $87BF : db |‥[end]|
C39546:  dw $883F : db |‥[end]|
C3954A:  dw $846F : db |すばやさ[end]|		; Speed		=== SNES: +40h as no diacritics (same below)
C39551:  dw $85EF : db |こうげきりょく[end]|		; Bat.Pwr
C3955B:  dw $866F : db |ぼうぎょ[end]|		; Defense
C39562:  dw $876F : db |まほうぼうぎょ[end]|		; Mag.Def
C3956C:  dw $7B4D : db |はんげん[end]|		; 50% Dmg
C39573:  dw $7B69 : db |きゅうしゅう[end]|		; Absorb HP
C3957C:  dw $7C4D : db |むこう[end]|		; No Effect
C39582:  dw $7C69 : db |じゃくてん[end]|		; Weak pt
C3958A:  dw $7B4D : db |こうげき[end]|		; Attack
C39591:  dw $822F : db |ひっさつけん OK[end]|		; SwdTech	=== SFC appends "OK"
C3959D:  dw $82AF : db |まふうけん  OK[end]|		; Runic
C395A9:  dw $832F : db |りょうてもち OK[end]|		; 2-hand

; Positioned text for item usage menu, "Owned:"
C395B5:  dw $79CD : db |もっているかず[end]|			=== SNES: +40h as no diacritics

; Positioned spaces for blanking item count in Item menu
C395BF:  dw $7ABF : db "   ",$00

; Load navigation data for Equip menu options
C395C5:  LDY #C395D4     ; C3/95D4
         JMP C30681      ; Load navig data

; Handle D-Pad for Equip menu options
C395CB:  JSR C307B0      ; Handle D-Pad
C395CE:  LDY #C395D9     ; C3/95D9
         JMP C306C3      ; Relocate cursor

; Navigation data for Equip menu options
C395D4:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $04          ; 4 columns
         db $01          ; 1 row

; Cursor positions for Equip menu options
C395D9:  dw $1010        ; EQUIP			=== SNES: Shifted rightward
         dw $1038        ; OPTIMUM
         dw $1070        ; RMOVE			=== SNES: Shifted rightward
         dw $10A0        ; EMPTY			=== SNES: Shifted rightward

; Load navigation data for Equip menu slot selection
C395E1:  LDY #C395F0     ; C3/95F0
         JMP C30681      ; Load navig data

; Handle D-Pad for Equip menu slot selection
C395E7:  JSR C307B0      ; Handle D-Pad
C395EA:  LDY #C395F5     ; C3/95F5
         JMP C306C3      ; Relocate cursor

; Navigation data for Equip menu slot selection
C395F0:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $04          ; 4 rows

; Cursor positions for Equip menu slot selection
C395F5:  dw $2C38        ; R-Hand			=== SNES: All point at body parts instead of item names
         dw $3838        ; L-Hand
         dw $4438        ; Head
         dw $5038        ; Body

; Load navigation data for equipment browsing
C395FD:  LDY #C3961B     ; C3/961B
         JMP C30681      ; Load navig data

; Handle D-Pad for equipment browsing (over 9 items)
C39603:  JSR C38948      ; Handle D-Pad
C39606:  LDY #C39620     ; C3/9620
         JMP C306CB      ; Relocate cursor

; Load navigation data for equipment browsing
C3960C:  LDY #C3961B     ; C3/961B
         JMP C30681      ; Load navig data

; Handle D-Pad for equipment browsing (9 items or less)
C39612:  JSR C307B0      ; Handle D-Pad
C39615:  LDY #C39620     ; C3/9620
         JMP C306C3      ; Relocate cursor

; Navigation data for equipment list
C3961B:  db $81          ; Never wraps
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $09          ; 9 rows

; Cursor positions for equipment list
C39620:  dw $6800        ; Item 1
         dw $7400        ; Item 2
         dw $8000        ; Item 3
         dw $8C00        ; Item 4
         dw $9800        ; Item 5
         dw $A400        ; Item 6
         dw $B000        ; Item 7
         dw $BC00        ; Item 8
         dw $C800        ; Item 9

; Load navigation data for Relic menu options
C39632:  LDY #C39641     ; C3/9641
         JMP C30681      ; Load navig data

; Handle D-Pad for Relic menu options
C39638:  JSR C307B0      ; Handle D-Pad
C3963B:  LDY #C39646     ; C3/9646
         JMP C306C3      ; Relocate cursor

; Navigation data for Relic menu options
C39641:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $02          ; 2 columns
         db $01          ; 1 row

; Cursor positions for Relic menu options
C39646:  dw $1010        ; Equip
         dw $1038        ; Remove			=== SNES: Shifted rightward

; Load navigation data for relic slot selection
C3964A:  LDY #C39659     ; C3/9659
         JMP C30681      ; Load navig data

; Handle D-Pad for relic slot selection
C39650:  JSR C307B0      ; Handle D-Pad
C39653:  LDY #C3965E     ; C3/965E
         JMP C306C3      ; Relocate cursor

; Navigation data for relic slot selection
C39659:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $02          ; 2 rows

; Cursor positions for relic slots
C3965E:  dw $4438        ; Relic 1			=== SNES: Both point at "Relic" instead of item name
         dw $5038        ; Relic 2

; Draw party gear overview
C39662:  LDA #$02        ; 32x64 at $0000
         STA $2107       ; Set BG1 map loc
         JSR C371BC      ; Clear BG2 map A
         LDY #C397D7     ; C3/97D7
         JSR C303C4      ; Draw window
         JSR C30EBD      ; Upload window
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C39691      ; Handle member 1
         JSR C396B8      ; Handle member 2
         JSR C396E1      ; Handle member 3
         JSR C3970A      ; Handle member 4
         JSR C30E93      ; Upload BG1 A+B
         JSR C30EA1      ; Upload BG1 C...
         JSR C371D0      ; Clear BG3 map A
         JMP C30ED9      ; Upload BG3 A+B

; Draw text in party gear overview for member 1
C39691:  LDA $69         ; Nobody here?
         BMI C396B7      ; Exit if so
         LDA #$24        ; Palette 1			%%% SNES: Body parts not listed (same for all members)
         STA $29         ; Color: Blue
         LDX #C3A9F8     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw body parts
         LDX $6D         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$38CD      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         STZ $28         ; Member slot: 1
         LDA #$04        ; Base Y: 4
         JSR C39733      ; Draw equipment
C396B7:  RTS

; Draw text in party gear overview for member 2
C396B8:  LDA $6A         ; Nobody here?
         BMI C396E0      ; Exit if so
         LDA #$24        ; Palette 1			%%%
         STA $29         ; Color: Blue
         LDX #C3AA04     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw body parts
         LDX $6F         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$3ACD      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$01        ; Member: 2
         STA $28         ; Set member slot
         LDA #$0C        ; Base Y: 12
         JSR C39733      ; Draw equipment
C396E0:  RTS

; Draw text in party gear overview for member 3
C396E1:  LDA $6B         ; Nobody here?
         BMI C39709      ; Exit if so
         LDA #$24        ; Palette 1			%%%
         STA $29         ; Color: Blue
         LDX #C3AA10     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw body parts
         LDX $71         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$3CCD      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$02        ; Member: 3
         STA $28         ; Set member slot
         LDA #$14        ; Base Y: 20
         JSR C39733      ; Draw equipment
C39709:  RTS

; Draw text in party gear overview for member 4
C3970A:  LDA $6C         ; Nobody here?
         BMI C39732      ; Exit if so
         LDA #$24        ; Palette 1			%%%
         STA $29         ; Color: Blue
         LDX #C3AA1C     ; Text ptrs loc
         LDY #$000C      ; Strings: 6
         JSR C3714E      ; Draw body parts
         LDX $73         ; Actor's address
         STX $67         ; Memorize it
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$3ECD      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$03        ; Member: 4
         STA $28         ; Set member slot
         LDA #$1C        ; Base Y: 28
         JSR C39733      ; Draw equipment
C39732:  RTS

; Draw member's gear in party gear overview
C39733:  STA $E2         ; Set base Y
         STZ $E0         ; ...
         LDY $67         ; Actor's address
         TDC             ; Clear A
         TAX             ; 1st: R-Hand
C3973B:  PHX             ; Push gear slot
         PHY             ; Push actor adr
         PHY             ; Push actor adr
         PHX             ; Push gear slot
         STZ $E5         ; X-Pos HB: 0
         LDA.L C3977E,X  ; X position
         STA $E4         ; Memorize it
         LDA.L C39784,X  ; Relative Y
         CLC             ; Prepare ADC
         ADC $E2         ; Add base Y
         LDX $E4         ; X position
         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         PLX             ; Gear slot
         CPX #$0002      ; Either hand?
         BCS C39767      ; Branch if not
         JSR C39C0C      ; Test "Empty"
         BRA C39769      ; Skip a line
C39767:  STZ $E0         ; Forbid "Empty"
C39769:  PLY             ; Actor's address
         TDC             ; ...
         LDA $001F,Y     ; Item in slot
         JSR C3978A      ; Load name
         JSR C387B9      ; Draw name
         PLY             ; Actor's address
         INY             ; Reach next slot
         PLX             ; Gear slot
         INX             ; Point to next
         CPX #$0006      ; Done 6 slots?
         BNE C3973B      ; Loop if not
         RTS

; X positions for party gear overview			=== SNES: They all differ because body parts are not listed
C3977E:  db $07          ; R-Hand
         db $15          ; L-Hand
         db $07          ; Head
         db $15          ; Body
         db $07          ; Relic 1
         db $15          ; Relic 2

; Relative Y positions for party gear overview		=== SNES: Shifted down as no diacritics
C39784:  db $00          ; R-Hand
         db $00          ; L-Hand
         db $02          ; Head
         db $02          ; Body
         db $04          ; Relic 1
         db $04          ; Relic 2

; Load equipped item's name
C3978A:  PHA             ; Save item
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
C39791:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C39791      ; Loop if not
         TDC             ; Clear A
         LDA $E0         ; Allow "Empty"?
         BEQ C397A0      ; Branch if not
         PLA             ; Item
         BRA C397A5      ; Skip next check
C397A0:  PLA             ; Item
         CMP #$FF        ; None?
         BEQ C397C8      ; Blank if so
C397A5:  STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$09        ; Name data size		=== SNES: 13
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDX $2134       ; Index product
         LDY #$0009      ; Letters: 9			=== SNES: 13
C397B9:  LDA $E6F700,X   ; Letter			=== SNES: $D2B300
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C397B9      ; Loop till last
         STZ $2180       ; End string
         RTS

; Fork: Blank item name
C397C8:  LDY #$0009      ; Spaces: 9			=== SNES: 13
         LDA #$FF        ; Space char
C397CD:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C397CD      ; Loop till last
         STZ $2180       ; End string
         RTS

; Window layout for party gear overview
C397D7:  dw $588B,$181C  ; 30x26 at $588B

; Draw Equip menu, create portrait, update status via gear
C397DB:  JSR C3983C      ; Do boxes; face
         JSR C398C4      ; Draw info; status
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C3AABC     ; Text ptrs loc
         LDY #$0004      ; Strings: 2
         JSR C3714E      ; Draw Head, Body
         JSR C397F7      ; Draw top options
         JSR C30ED9      ; Upload BG3 A+B
         JMP C3A61D      ; Queue text upload

; Draw options in Equip menu
C397F7:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C3AAB4     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3714E      ; Draw text
         RTS

; Draw options in Relic menu
C39805:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C3AAC0     ; Text ptrs loc
         LDY #$0004      ; Strings: 2
         JSR C3714E      ; Draw text
         RTS

; Draw Relic menu, memorize original relics, create portrait
C39813:  JSR C3983C      ; Do boxes; face
         JSR C39BE1      ; Define Y
         LDA $0023,Y     ; Relic 1
         STA $B0         ; Save for Reequip
         LDA $0024,Y     ; Relic 2
         STA $B1         ; Save for Reequip
         JSR C398DA      ; Draw info; status
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C3AAC4     ; Text ptrs loc
         LDY #$0004      ; Strings: 2
         JSR C3714E      ; Draw 2x "Relic"
         JSR C39805      ; Draw menu options
         JSR C3AFEE      ; Build desc map
         JMP C30ED9      ; Upload BG3 A+B

; Draw elements shared by Equip and Relic menus, create portrait
C3983C:  JSR C398B9      ; Load actor stats
         REP #$20        ; 16-bit A
         LDA #$0100      ; BG1 H-Shift: 256
         STA $7E9BD0     ; Hide gear list
         SEP #$20        ; 8-bit A
         LDA #$01        ; 64x32 at $0000
         STA $2107       ; Set BG1 map loc
         LDA #$42        ; 32x64 at $4000
         STA $2109       ; Set BG3 map loc
         JSR C39DFB      ; Reset BG2 X-Pos
         JSR C371BC      ; Clear BG2 map A
         JSR C371C1      ; Clear BG2 map B
         LDY #C39C6E     ; C3/9C6E
         JSR C303C4      ; Draw stats box A
         LDY #C39C72     ; C3/9C72
         JSR C303C4      ; Draw gear box A
         LDY #C39C76     ; C3/9C76
         JSR C303C4      ; Draw option box
         LDY #C39C7A     ; C3/9C7A
         JSR C303C4      ; Draw stats box B
         LDY #C39C7E     ; C3/9C7E
         JSR C303C4      ; Draw gear box B
         LDY #C39C82     ; C3/9C82
         JSR C303C4      ; Draw title box
         JSR C30EBD      ; Upload windows
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C30E93      ; Upload BG1 A+B
         JSR C30EA1      ; Upload BG1 C...
         JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         JSR C39BCE      ; Draw actor name
         JSR C36808      ; Create portrait
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDX #C3AB44     ; Text ptrs loc
         LDY #$001C      ; Strings: 14
         JSR C3712C      ; Draw Vigor, etc.
         LDA #$2C        ; ...
         STA $29         ; ...
         LDX #C3AB60     ; Text ptrs loc
         LDY #$0008      ; Strings: 4
         JSR C3714E      ; Draw Speed, etc.
         JMP C30ED9      ; Upload BG3 A+B

; Load member's stats and properties with gear
C398B9:  TDC             ; Clear A
         LDA $28         ; Member slot
         TAX             ; Index it
         LDA $69,X       ; Actor
         JSL $C20006     ; Load data
         RTS

; Draw actor info in Equip menu, update status based on gear
C398C4:  JSR C3A164      ; Draw hand names
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C398E7      ; Do stats; status
         JSR C399D6      ; Draw relic FX		=== SNES: Removed feature
         JSR C39BEB      ; Draw arms
         JSR C39C24      ; Draw helmet
         JMP C39C32      ; Draw armor

; Draw actor info in Relic menu, update status based on gear
C398DA:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C398E7      ; Do stats; status
         JSR C39C40      ; Draw relic 1
         JMP C39C4E      ; Draw relic 2

; Draw current stats in gear menu, update status based on gear
C398E7:  JSR C398B9      ; Load actor stats
         JSR C39BE1      ; Actor's address
         JSR C3A1D7      ; Set Bat.Pwr mode
         JSR C399B0      ; Relocate stats
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         JSR C3996D      ; Update status
         LDA $3006       ; Vigor
         JSR C30563      ; Turn into text
         LDX #$7CB7      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $3004       ; Speed
         JSR C30563      ; Turn into text
         LDX #$7D37      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $3002       ; Stamina
         JSR C30563      ; Turn into text
         LDX #$7DB7      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $3000       ; Mag.Pwr
         JSR C30563      ; Turn into text
         LDX #$7E37      ; Text position
         JSR C30543      ; Draw 3 digits
         JSR C39B94      ; Define Bat.Pwr
         LDX $F1         ; Load it
         STX $F3         ; Save for $05B1
         JSR C305B1      ; Turn into text
         LDX #$7EB7      ; Text position
         JSR C30509      ; Draw 3 digits
         LDA $301A       ; Defense
         JSR C30563      ; Turn into text
         LDX #$7F37      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $3008       ; Evade
         JSR C30563      ; Turn into text
         LDX #$7FB7      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $301B       ; Mag.Def
         JSR C30563      ; Turn into text
         LDX #$8037      ; Text position
         JSR C30543      ; Draw 3 digits
         LDA $300A       ; MBlock
         JSR C30563      ; Turn into text
         LDX #$80B7      ; Text position
         JSR C30543      ; Draw 3 digits
         PLB             ; Restore DB
         RTS

; Update status based on gear (Rage denotes Auto Float)
C3996D:  JSR C39BE1      ; Define Y
         LDA $7E3032     ; Gear immunity
         JSR C39995      ; Deny ailments
         LDA $3034       ; Gear auto status
         AND #$01        ; Float?
         BNE C39985      ; Branch if so
         LDA $0015,Y     ; Actor's status
         AND #$01        ; Rage?
         BEQ C39994      ; Exit if not
C39985:  LDA $3034       ; Gear auto status
         CLC             ; Prepare ROR
         AND #$01        ; Get Float
         STA $E0         ; Memorize it
         ROR A           ; Put in Carry
         ROR A           ; Put in bit 7
         ORA $E0         ; Add Float as Rage
         STA $0015,Y     ; Set actor status
C39994:  RTS

; Cure ailments blocked by gear
C39995:  AND #$25        ; Dark, Poison, Imp
         EOR #$FF        ; Toggle all bits
         STA $E1         ; Save immunities
         LDA $0014,Y     ; Actor's status
         AND $E1         ; Lift immune ones
         STA $0014,Y     ; Save changes
         RTS

; Grant Float status if bestowed by gear
C399A4:  CLC             ; Prepare ROR
         AND #$01        ; Auto Float
         ROR A           ; Put in Carry
         ROR A           ; Put in bit 7
         ORA $0015,Y     ; Add status
         STA $0015,Y     ; Set status
         RTS

; Load actor's info for Equip or Relic menu
C399B0:  LDX $00         ; 1st: Mag.Pwr
         REP #$20        ; 16-bit A
C399B4:  LDA $11A0,X     ; Actor info
         STA $7E3000,X   ; Set as current
         INX             ; Index +1
         INX             ; Index +1
         LDA $11A0,X     ; Actor info
         STA $7E3000,X   ; Set as current
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0040      ; Done 64 bytes?
         BNE C399B4      ; Loop if not
         SEP #$20        ; 8-bit A
         LDA $A1         ; 2-hand flag
         STA $A0         ; Set as current
         LDA $CD         ; Genji G. flag
         STA $CE         ; Set as current
         RTS

; Draw relic effects in Equip menu			%%%
C399D6:  LDY #C3ABD6     ; Text pointer
         JSR C30326      ; Blank effect A
         LDY #C3ABDF     ; Text pointer
         JSR C30326      ; Blank effect B
         LDA $11D8       ; Gear effects
         AND #$20        ; Merit Award?
         BEQ C399F2      ; Branch if not
         JSR C39A17      ; Color: Blue
         LDY #C3ABE8     ; Text pointer
         JSR C30326      ; B: "Heavy gear"
C399F2:  LDA $11D8       ; Gear effects
         AND #$10        ; Genji Glove?
         BEQ C39A02      ; Branch if not
         JSR C39A17      ; Color: Blue
         LDY #C3ABF1     ; Text pointer
         JSR C30326      ; A: "Dual wield"
C39A02:  LDA $11D8       ; Gear effects
         AND #$08        ; Gauntlet?
         BEQ C39A12      ; Exit if not
         JSR C39A17      ; Color: Blue
         LDY #C3ABFA     ; Text pointer
         JSR C30326      ; B: "Two-handed"
C39A12:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         RTS             ; ^ For gear

; Set text color to blue
C39A17:  LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         RTS

; Draw projected stats in Equip or Relic menu
C39A1C:  LDA $7E9D89     ; Empty item list?
         BEQ C39A27      ; Abort if so
         JSR C3A231      ; On a gray item?
         BCS C39A2A      ; Branch if not
C39A27:  JMP C3A476      ; Clear stats
C39A2A:  JSR C39BE1      ; Actor's address
         LDA $25         ; Submenu
         CMP #$02        ; Equip menu?
         BEQ C39A37      ; Branch if so
         INY             ; Point to L-Hand
         INY             ; Point to head
         INY             ; Point to body
         INY             ; Point to relic 1
C39A37:  REP #$21        ; 16-bit A; C-
         TYA             ; Actor's address
         SEP #$20        ; 8-bit A
         ADC $5F         ; Add body slot
         TAY             ; Index sum
         TDC             ; Clear A
         LDA $4B         ; Gear list slot
         TAX             ; Index it
         LDA $7E9D8A,X   ; Inventory slot
         TAX             ; Index it
         LDA $001F,Y     ; Equipped item
         STA $64         ; Preserve it
         LDA $1869,X     ; Inventory item
         STA $001F,Y     ; Put on actor
         PHY             ; Save actor adr
         JSR C398B9      ; Load actor data
         JSR C39BE1      ; Base actor adr
         JSR C3A1D7      ; Set Bat.Pwr mode
         JSR C39B09      ; Set stat colors
         LDA $11A6       ; New Vigor
         JSR C30563      ; Turn into text
         LDX #$7CBF      ; Text position
         LDA $7E3040     ; Vigor palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         LDA $11A4       ; New Speed
         JSR C30563      ; Turn into text
         LDX #$7D3F      ; Text position
         LDA $7E3041     ; Speed palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         LDA $11A2       ; New Stamina
         JSR C30563      ; Turn into text
         LDX #$7DBF      ; Text position
         LDA $7E3042     ; Stamina palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         LDA $11A0       ; New Mag.Pwr
         JSR C30563      ; Turn into text
         LDX #$7E3F      ; Text position
         LDA $7E3043     ; Mag.Pwr palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         JSR C39B5A      ; Define Bat.Pwr
         JSR C305B1      ; Turn into text
         LDX #$7EBF      ; Text position
         LDA $7E3048     ; Bat.Pwr palette
         STA $29         ; Set as current
         JSR C30509      ; Draw 3 digits
         LDA $11BA       ; New Defense
         JSR C30563      ; Turn into text
         LDX #$7F3F      ; Text position
         LDA $7E3044     ; Defense palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         LDA $11A8       ; New Evade
         JSR C30563      ; Turn into text
         LDX #$7FBF      ; Text position
         LDA $7E3045     ; Evade palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         LDA $11BB       ; New Mag.Def
         JSR C30563      ; Turn into text
         LDX #$803F      ; Text position
         LDA $7E3046     ; Mag.Def palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         LDA $11AA       ; New MBlock
         JSR C30563      ; Turn into text
         LDX #$80BF      ; Text position
         LDA $7E3047     ; MBlock palette
         STA $29         ; Set as current
         JSR C30543      ; Draw 3 digits
         PLY             ; Actor address
         LDA $64         ; Original item
         STA $001F,Y     ; Restore gear
         RTS

; Set color for each projected stat in Equip or Relic menu
C39B09:  PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         TAX             ; Stat index: 0
C39B10:  LDA.L C39B52,X  ; Stat pointer
         PHX             ; Save index
         TAX             ; Index pointer
         LDA $0011A0,X   ; Projected stat
         CMP $3000,X     ; Matches old?
         BEQ C39B25      ; Branch if so
         BCC C39B29      ; Gray if less
         LDA #$28        ; Palette 2
         BRA C39B2B      ; Color: Yellow

; Fork: Use player's color
C39B25:  LDA #$20        ; Palette 0
         BRA C39B2B      ; Skip a line

; Fork: Gray out statistic
C39B29:  LDA #$24        ; Palette 1
C39B2B:  PLX             ; Stat index
         STA $3040,X     ; Set stat color
         INX             ; Stat index +1
         CPX #$0008      ; Done 8 stats?
         BNE C39B10      ; Loop if not

; Fork: Handle Bat.Pwr
C39B35:  JSR C39B5A      ; Set new Bat.Pwr
         JSR C39B94      ; Set old Bat.Pwr
         LDY $F3         ; New Bat.Pwr
         CPY $F1         ; Matches old?
         BEQ C39B47      ; Branch if so
         BCC C39B4B      ; Gray if less
         LDA #$28        ; Palette 2
         BRA C39B4D      ; Font: Yellow

; Fork: Use player's color for Bat.Pwr
C39B47:  LDA #$20        ; Palette 0
         BRA C39B4D      ; Skip a line

; Fork: Gray out Bat.Pwr
C39B4B:  LDA #$24        ; Palette 1
C39B4D:  STA $3048       ; Set BP color
         PLB             ; Restore DB
         RTS

; Ordered index list for loading stats
C39B52:  db $06          ; Vigor
         db $04          ; Speed
         db $02          ; Stamina
         db $00          ; Mag.Pwr
         db $1A          ; Defense
         db $08          ; Evade
         db $1B          ; Mag.Def
         db $0A          ; MBlock

; Define current (Status) or projected (Equip, Relic) Bat.Pwr
C39B5A:  LDA $A1         ; 2-hand mode?
         BEQ C39B74      ; Branch if not
         LDA $0011AC     ; R-Hand's power
         BEQ C39B6A      ; Branch if 0
         STA $0011AD     ; Set as L-Hand's
         BRA C39B83      ; Combine hands

; Fork: Two-handing L-Hand weapon
C39B6A:  LDA $0011AD     ; L-Hand's power
         STA $0011AC     ; Set as R-Hand's
         BRA C39B83      ; Combine hands

; Fork: Not two-handing a weapon
C39B74:  LDA $CD         ; Got Genji Glove?
         BNE C39B83      ; Branch if so
         LDA $0011AC     ; R-Hand's power
         BEQ C39B83      ; Branch if 0
         TDC             ; Bat.Pwr: 0
         STA $0011AD     ; Set L-Hand's

; Fork: Combine hands' Bat.Pwr
C39B83:  LDA $0011AC     ; R-Hand's power
         CLC             ; Prepare ADC
         ADC $0011AD     ; Add L-Hand's
         STA $F3         ; Set Bat.Pwr LB
         TDC             ; Zero A
         ADC #$00        ; +1 if overflow
         STA $F4         ; Set Bat.Pwr HB
         RTS

; Define current Bat.Pwr for Equip or Relic menu
C39B94:  LDA $A0         ; 2-hand mode?
         BEQ C39BAE      ; Branch if not
         LDA $7E300C     ; R-Hand's power
         BEQ C39BA4      ; Branch if 0
         STA $7E300D     ; Set as L-Hand's
         BRA C39BBD      ; Combine hands

; Fork: Two-handing L-Hand weapon
C39BA4:  LDA $7E300D     ; L-Hand's power
         STA $7E300C     ; Set as R-Hand's
         BRA C39BBD      ; Combine hands

; Fork: Not two-handing a weapon
C39BAE:  LDA $CE         ; Got Genji Glove?
         BNE C39BBD      ; Branch if so
         LDA $7E300C     ; R-Hand's power
         BEQ C39BBD      ; Branch if 0
         TDC             ; Bat.Pwr: 0
         STA $7E300D     ; Set L-Hand's

; Fork: Combine hands' Bat.Pwr
C39BBD:  LDA $7E300C     ; R-Hand's power
         CLC             ; Prepare ADC
         ADC $7E300D     ; Add L-Hand's
         STA $F1         ; Set Bat.Pwr LB
         TDC             ; Zero A
         ADC #$00        ; +1 if overflow
         STA $F2         ; Set Bat.Pwr HB
         RTS

; Draw actor name and class in Equip or Relic menu	=== SNES: No class
C39BCE:  JSR C39BE1      ; Actor's address
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$7AEF      ; Text position		=== SNES: Shifted down-rightward
         JSR C3356A      ; Draw actor name
         LDY #$7B6F      ; Text position		%%%
         JMP C33580      ; Draw actor class

; Load member's SRAM block address
C39BE1:  TDC             ; Clear A
         LDA $28         ; Member slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Address
         STY $67         ; Memorize it
         RTS

; Draw equipped armaments in Equip menu
C39BEB:  JSR C39C0C      ; Test Empty x2
         LDX #$79DB      ; Tilemap ptr			=== SNES: +40h as no diacritics
         JSR C39C5C      ; Set Y, coords
         LDA $001F,Y     ; R-Hand item
         JSR C3978A      ; Load name
         JSR C387B9      ; Draw name
         JSR C39C0C      ; Test Empty x2
         LDX #$7A5B      ; Tilemap ptr			=== SNES: +40h as no diacritics
         JSR C39C5C      ; Set Y, coords
         LDA $0020,Y     ; L-Hand item
         JMP C39C68      ; Draw name

; Check if "Empty" should be drawn for both hands
C39C0C:  JSR C39BE1      ; Define Y
         LDA $001F,Y     ; R-Hand item
         CMP #$FF        ; Nothing?
         BNE C39C21      ; Forbid if not
         LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; Nothing?
         BNE C39C21      ; Forbid if not
         STA $E0         ; Allow "Empty"
         BRA C39C23      ; Exit
C39C21:  STZ $E0         ; Forbid "Empty"
C39C23:  RTS

; Draw equipped helmet in Equip menu
C39C24:  LDX #$7ADB      ; Tilemap ptr			=== SNES: +40h as no diacritics
         JSR C39C5C      ; Set Y, coords
         STZ $E0         ; Forbid "Empty"
         LDA $0021,Y     ; Helmet
         JMP C39C68      ; Draw its name

; Draw equipped armor in Equip menu
C39C32:  LDX #$7B5B      ; Tilemap ptr			=== SNES: +40h as no diacritics
         JSR C39C5C      ; Set Y, coords
         STZ $E0         ; Forbid "Empty"
         LDA $0022,Y     ; Armor
         JMP C39C68      ; Draw its name

; Draw equipped relic 1 in Relic menu
C39C40:  LDX #$7ADB      ; Tilemap ptr			=== SNES: +40h as no diacritics
         JSR C39C5C      ; Set Y, coords
         STZ $E0         ; Forbid "Empty"
         LDA $0023,Y     ; Relic 1
         JMP C39C68      ; Draw its name

; Draw equipped relic 2 in Relic menu
C39C4E:  LDX #$7B5B      ; Tilemap ptr			=== SNES: +40h as no diacritics
         JSR C39C5C      ; Set Y, coords
         STZ $E0         ; Forbid "Empty"
         LDA $0024,Y     ; Relic 2
         JMP C39C68      ; Draw its name

; Set text position and load actor data address
C39C5C:  REP #$20        ; 16-bit A
         TXA             ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         JMP C39BE1      ; Load address

; Load and draw equipped item's name
C39C68:  JSR C3978A      ; Load item name
         JMP C387B9      ; Draw item name

; Window layout for Equip and Relic menus
C39C6E:  dw $5B4B,$0D1C  ; 30x15 at $5B4B (Stats w/o title)
C39C72:  dw $590B,$071C  ; 30x09 at $590B (Gear w/o title)
C39C76:  dw $588B,$021C  ; 30x04 at $588B (Options)
C39C7A:  dw $634B,$0D1C  ; 30x15 at $634B (Stats w/ title)
C39C7E:  dw $610B,$071C  ; 30x09 at $610B (Gear w/ title)
C39C82:  dw $60B9,$0205  ; 07x04 at $60B9 (Title)	=== SNES: Expanded leftward

; Set to condense text for party gear overview or final battle lineup
C39C86:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$0E        ; $210E
         STA $4351       ; To BG1 V-Scroll
         LDY #C39DC7     ; C3/9DC7
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; Set to condense text in Equip or Relic menu
C39CA5:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set CH5 mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C39DC7     ; C3/9DC7
         STY $4352       ; Set CH5 src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set CH5 src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         JSR C39D0F      ; Load BG1 V-Data
         LDX $00         ; Index: 0
C39CC8:  LDA.L C39D53,X  ; BG1 H-Pan data
         STA $7E9BC9,X   ; Save in RAM
         INX             ; Index +1
         CPX #$000D      ; End of table?
         BNE C39CC8      ; Loop if not
         LDA #$02        ; 1Rx2B to PPU
         STA $4360       ; Set CH6 mode
         LDA #$0D        ; $210D
         STA $4361       ; To BG1 H-Scroll
         LDY #$9BC9      ; 7E/9BC9
         STY $4362       ; Set CH6 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4364       ; Set CH6 src HB
         LDA #$7E        ; ...
         STA $4367       ; Set indir HB
         LDA #$02        ; 1Rx2B to PPU
         STA $4370       ; Set CH7 mode
         LDA #$0E        ; $210E
         STA $4371       ; To BG1 V-Scroll
         LDY #$9849      ; 7E/9849
         STY $4372       ; Set CH7 src LBs
         LDA #$7E        ; Bank: 7E
         STA $4374       ; Set CH7 src HB
         LDA #$7E        ; ...
         STA $4377       ; Set indir HB
         LDA #$C0        ; Channels: 6, 7
         TSB $43         ; Queue HDMA 6+7
         RTS

; Load BG1 vertical shift table for Equip or Relic menu
C39D0F:  LDX $00         ; Index: 0
C39D11:  LDA.L C39D60,X  ; Void's V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         CPX #$0012      ; At item data?
         BNE C39D11      ; Loop if not
C39D1F:  LDA.L C39D60,X  ; Scanline data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         TDC             ; Clear A
         LDA $49         ; BG1 top row
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         AND #$FF        ; ...
         REP #$21        ; 16-bit A; C-
         ADC.L C39D60,X  ; Add V-Pan data
         STA $7E9849,X   ; Save in RAM
         SEP #$20        ; 8-bit A
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0063      ; Beyond list?
         BNE C39D1F      ; Loop if not
C39D44:  LDA.L C39D60,X  ; Void's V-Data
         STA $7E9849,X   ; Save in RAM
         INX             ; Index +1
         CPX #$0067      ; End of table?
         BNE C39D44      ; Loop if not
         RTS

; BG1 H-Shift table for gear list browsing
C39D53:  db $27,$00,$01  ; Nothing?
         db $3C,$00,$01  ; Nothing?
         db $6C,$00,$00  ; Item list
         db $1E,$00,$01  ; Nothing?
         db $00          ; End

; BG1 V-Shift table for gear list browsing
C39D60:  db $3F,$00,$00  ; Nothing?
         db $0C,$04,$00  ; Nothing?
         db $0C,$08,$00  ; Nothing?
         db $0A,$0C,$00  ; Nothing?
         db $01,$0C,$00  ; Nothing?
         db $01,$0C,$00  ; Nothing?
         db $04,$A0,$FF  ; Item row 1
         db $04,$A0,$FF  ; Item row 2
         db $04,$A0,$FF  ; Item row 3
         db $04,$A4,$FF  ; Item row 4
         db $04,$A4,$FF  ; Item row 5
         db $04,$A4,$FF  ; Item row 6
         db $04,$A8,$FF  ; Item row 7
         db $04,$A8,$FF  ; Item row 8
         db $04,$A8,$FF  ; Item row 9
         db $04,$AC,$FF  ; Item row 10
         db $04,$AC,$FF  ; Item row 11
         db $04,$AC,$FF  ; Item row 12
         db $04,$B0,$FF  ; Item row 13
         db $04,$B0,$FF  ; Item row 14
         db $04,$B0,$FF  ; Item row 15
         db $04,$B4,$FF  ; Item row 16
         db $04,$B4,$FF  ; Item row 17
         db $04,$B4,$FF  ; Item row 18
         db $04,$B8,$FF  ; Item row 19
         db $04,$B8,$FF  ; Item row 20
         db $04,$B8,$FF  ; Item row 21
         db $04,$BC,$FF  ; Item row 22
         db $04,$BC,$FF  ; Item row 23
         db $04,$BC,$FF  ; Item row 24
         db $04,$C0,$FF  ; Item row 25
         db $04,$C0,$FF  ; Item row 26
         db $04,$C0,$FF  ; Item row 27
         db $1E,$10,$00  ; Nothing?
         db $00          ; End

; V-Shift table for gear menus and final battle lineup
C39DC7:  db $0F,$00,$00  ; Nothing
         db $0C,$04,$00  ; Options, title
         db $0C,$08,$00  ; Reequip mode
         db $0C,$0C,$00  ; R-Hand
         db $0C,$10,$00  ; L-Hand
         db $0C,$14,$00  ; Head, Relic 1
         db $0C,$18,$00  ; Body, Relic 2
         db $0C,$1C,$00  ; Member 2's armor
         db $0C,$20,$00  ; Vigor
         db $0C,$24,$00  ; Speed
         db $0C,$28,$00  ; Stamina
         db $0C,$2C,$00  ; Mag.Pwr
         db $0C,$30,$00  ; Bat.Pwr
         db $0C,$34,$00  ; Defense
         db $0C,$38,$00  ; Evade
         db $0C,$3C,$00  ; Mag.Def
         db $0C,$40,$00  ; MBlock
         db $00          ; End

; Switch to layout with options in Equip or Relic menu
C39DFB:  JSR C39E4C      ; Erase title
         LDY $00         ; X: 0
         STY $39         ; Set BG2 X-Pos
         RTS

; Switch to layout without options in Equip or Relic menu
C39E03:  JSR C39E4C      ; Erase options
         LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         RTS             ; ^ For "Equip"

; 36: Handle Equip menu options
C39E10:  JSR C39DFB      ; Switch windows
         JSR C397F7      ; Draw options
         JSR C395CB      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C39E24      ; Branch if not
         JSR C30F1D      ; Sound: Click
         BRA C39E53      ; Handle selection

; Fork: Handle B
C39E24:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C39E37      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JSR C398B9      ; Update field FX
         LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Handle L and R, prepare for menu reset
C39E37:  LDA #$35        ; C3/1C1E
         STA $E0         ; Set init command
         JMP C32088      ; Handle L and R

; Draw blue "Equip" in Equip or Relic menu
C39E3E:  LDY #C3AB0E     ; Text pointer
         JSR C30326      ; Draw title
         RTS

; Draw blue "Remove" in Equip or Relic menu
C39E45:  LDY #C3AB14     ; Text pointer
         JSR C30326      ; Draw title
         RTS

; Erase options and title in Equip or Relic menu
C39E4C:  LDY #C3AAF1     ; Text pointer
         JSR C30326      ; Draw 26 spaces		=== SNES: 28
         RTS

; Handle selected option in Equip menu
C39E53:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C39E5B,X)  ; Handle option

; Jump table for the above
C39E5B:  dw C39E63       ; EQUIP
         dw C39E74       ; OPTIMUM
         dw C39E7D       ; RMOVE
         dw C39E8E       ; EMPTY

; Handle "EQUIP" selection in Equip menu
C39E63:  JSR C39E03      ; Switch windows
         JSR C39E3E      ; Draw blue "EQUIP"
         JSR C395E1      ; Load navig data
         JSR C395EA      ; Relocate cursor
         LDA #$55        ; C3/A073
         STA $26         ; Next: Slot choice
         RTS

; Handle "OPTIMUM" selection in Equip menu
C39E74:  JSR C39EDF      ; Optimize gear
         JSR C398C4      ; Redo text, status
         STZ $4D         ; Cursor: "USE"
         RTS

; Handle "RMOVE" selection in Equip menu
C39E7D:  JSR C39E03      ; Switch windows
         JSR C39E45      ; Draw blue "REMOVE"
         JSR C395E1      ; Load navig data
         JSR C395EA      ; Relocate cursor
         LDA #$56        ; C3/A0BE
         STA $26         ; Next: Slot choice
         RTS

; Handle "EMPTY" selection in Equip menu
C39E8E:  JSR C39E97      ; Remove gear
         JSR C398C4      ; Redo text, status
         STZ $4D         ; Cursor: "USE"
         RTS

; Remove character's equipment
C39E97:  JSR C39BE1      ; Define Y
         LDA $001F,Y     ; R-Hand item
         JSR C3A56C      ; Put in stock
         LDA $0020,Y     ; L-Hand item
         JSR C3A56C      ; Put in stock
         LDA $0021,Y     ; Helmet
         JSR C3A56C      ; Put in stock
         LDA $0022,Y     ; Armor
         JSR C3A56C      ; Put in stock
         LDA #$FF        ; Empty item
         STA $001F,Y     ; Clear R-Hand
         STA $0020,Y     ; Clear L-Hand
         STA $0021,Y     ; Clear helmet
         STA $0022,Y     ; Clear armor
         RTS

; Optimize member's equipment (event command)
C39EC1:  JSR C37087      ; Get party info
         TDC             ; Clear A
         TAX             ; Member slot: 1
         LDA $0201       ; Actor to equip
C39EC9:  CMP $69,X       ; In member slot?
         BEQ C39ED5      ; Branch if so
         INX             ; Member slot +1
         CPX #$0004      ; Done 4 members?
         BNE C39EC9      ; Loop if not
C39ED3:  BRA C39ED3      ; Freeze game...
C39ED5:  TXA             ; Member slot
         STA $28         ; Memorize it
         JSR C398B9      ; ...
         JSR C39EDF      ; Optimize gear
         RTL

; Optimize character's equipment
C39EDF:  JSR C398B9      ; Get gear FX
         JSR C39E97      ; Remove gear
         JSR C39BE1      ; Actor's address
         STY $F3         ; Memorize it
         LDA $11D8       ; Gear effects
         AND #$08        ; Gauntlet?
         BEQ C39F09      ; Branch if not

; Fork: Put a two-handed weapon in R-Hand
C39EF1:  STZ $4B         ; ...
         JSR C3A348      ; ...
         JSR C39F84      ; Get valid items
         JSR C3A95E      ; Sort by power
         JSR C3A02E      ; Pick 2H weapon
         LDY $F3         ; Actor's address
         STA $001F,Y     ; Set R-Hand item
         JSR C3A5A5      ; Adjust stock
         BRA C39F5A      ; Handle helmet

; Fork: Put a weapon in R-Hand
C39F09:  STZ $4B         ; ...
         JSR C3A348      ; ...
         JSR C39F84      ; Get valid items
         JSR C3A95E      ; Sort by power
         LDY $F3         ; Actor's address
         JSR C3A008      ; Pick a weapon
         STA $001F,Y     ; Put in R-Hand
         JSR C3A5A5      ; Adjust stock
         LDA $11D8       ; Gear effects
         AND #$10        ; Genji Glove?
         BNE C39F40      ; Branch if so

; Fork: Put a shield in L-Hand
C39F26:  LDA #$01        ; ...
         STA $4B         ; ...
         JSR C3A348      ; ...
         JSR C39FC6      ; Get valid items
         JSR C3A95E      ; Sort by defense
         LDY $F3         ; Actor's address
         JSR C3A008      ; Pick a shield
         STA $0020,Y     ; Put in L-Hand
         JSR C3A5A5      ; Adjust stock
         BRA C39F5A      ; Handle helmet

; Fork: Put a weapon in L-Hand
C39F40:  LDA #$01        ; ...
         STA $4B         ; ...
         JSR C3A348      ; ...
         JSR C39F84      ; Get valid items
         JSR C3A95E      ; Sort by power
         LDY $F3         ; Actor's address
         JSR C3A008      ; Pick a weapon
         STA $0020,Y     ; Put in L-Hand
         JSR C3A5A5      ; Adjust stock
         BRA C39F5A      ; ...

; Fork: Optimize helmet
C39F5A:  LDA #$02        ; Target: Head
         STA $4B         ; Set body part
         JSR C3A348      ; Get valid items
         JSR C3A95E      ; Sort by defense
         LDY $F3         ; Actor's address
         JSR C3A008      ; Choose helmet
         STA $0021,Y     ; Put on actor
         JSR C3A5A5      ; Adjust stock

; Fork: Optimize armor
C39F6F:  LDA #$03        ; Target: Torso
         STA $4B         ; Set body part
         JSR C3A348      ; Get valid items
         JSR C3A95E      ; Sort by defense
         LDY $F3         ; Actor's address
         JSR C3A008      ; Choose armor
         STA $0022,Y     ; Put on actor
         JMP C3A5A5      ; Adjust stock

; Compile compatible weapons for Optimum
C39F84:  JSR C3A419      ; Init list
         JSR C3A430      ; Define compat
         LDX $00         ; Clear X
         TXY             ; Item slot: 1
C39F8D:  TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C39FB7      ; Skip if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$01        ; Weapon?
         BNE C39FB7      ; Skip if not
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         BIT $E7         ; Actor can use?
         BEQ C39FB7      ; Skip if not
         SEP #$20        ; 8-bit A
         TYA             ; Item slot
         STA $2180       ; Add to list
         INC $E0         ; List size +1
C39FB7:  SEP #$20        ; 8-bit A
         INY             ; Item slot +1
         CPY #$00FF      ; Done 255?...
         BNE C39F8D      ; Loop if not
         LDA $E0         ; List size
         STA $7E9D89     ; Save to list
         RTS

; Compile compatible shields for Optimum
C39FC6:  JSR C3A419      ; Init list
         JSR C3A430      ; Define compat
         LDX $00         ; Clear X
         TXY             ; Item slot: 1
C39FCF:  TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C39FF9      ; Skip if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$03        ; Shield?
         BNE C39FF9      ; Skip if not
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         BIT $E7         ; Actor can use?
         BEQ C39FF9      ; Skip if not
         SEP #$20        ; 8-bit A
         TYA             ; Item slot
         STA $2180       ; Add to list
         INC $E0         ; List size +1
C39FF9:  SEP #$20        ; 8-bit A
         INY             ; Item slot +1
         CPY #$00FF      ; Done 255?...
         BNE C39FCF      ; Loop if not
         LDA $E0         ; List size
         STA $7E9D89     ; Save to list
         RTS

; Select first non-excluded item in sorted list of compatible gear
C3A008:  PHY             ; Save Y
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         TAY             ; RAM index: 0
C3A010:  TDC             ; Clear A
         TAX             ; ROM index: 0
C3A012:  PHX             ; Save index
         TDC             ; ...
         LDA $9D8A,Y     ; Stock slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         PLX             ; ROM index
         CMP $ED82E4,X   ; Excluded?
         BEQ C3A02B      ; Skip if so
         INX             ; ROM index +1
         CPX #$000A      ; Tested 10?
         BNE C3A012      ; Loop if not
         PLB             ; Restore DB
         PLY             ; Restore Y
         RTS             ; Exit
C3A02B:  INY             ; RAM index +1
         BRA C3A010      ; Try next item

; Exclusions: Cursed Shld, Thornlet, Imp set, Atma Weapon, Drainer, Soul Sabre, Heal Rod


; Select first two-handed weapon from sorted list of compatible gear
C3A02E:  LDA $7E9D89     ; List size
         BEQ C3A070      ; Branch if 0
         STA $CB         ; Memorize it
         STZ $CC         ; Clear its HB
         TDC             ; Clear A
         TAY             ; RAM index: 0
C3A03A:  TDC             ; Clear A
         TAX             ; ROM index: 0
C3A03C:  PHX             ; Save index
         TDC             ; ...
         TYX             ; RAM index
         LDA $7E9D8A,X   ; Stock slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         PLX             ; ROM index
         CMP $ED82E4,X   ; Excluded?
         BEQ C3A067      ; Skip if so
         INX             ; ROM index +1
         CPX #$000A      ; Tested 10?
         BNE C3A03C      ; Loop if not
         STA $C9         ; Save item
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85013,X   ; Properties
         AND #$40        ; 2-hand OK?
         BEQ C3A067      ; Skip if not
         LDA $C9         ; Item
         RTS

; Fork: Try next weapon, ignore Gauntlet if no valid options
C3A067:  INY             ; RAM index +1
         CPY $CB         ; End of list?
         BNE C3A03A      ; Loop if not
         JSR C3A008      ; Pick 1H weapon
         RTS

; Fork: Default to empty item
C3A070:  LDA #$FF        ; Empty item
         RTS

; 55: Handle selection of gear slot to fill
C3A073:  JSR C395E7      ; Handle D-Pad
         JSR C3A164      ; Recolor hand names
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A0A3      ; Branch if not
         JSR C30F1D      ; Sound: Click
         LDA $4E         ; Cursor row
         STA $5F         ; Set body slot
         LDA #$57        ; C3/A0FE
         STA $26         ; Next: Item list
         JSR C3A348      ; Build item list
         JSR C3A95E      ; Sort it by power
         JSR C3A2DA      ; Cursor & Scrollbar
         LDA #$55        ; Return here if..
         STA $27         ; ..list is empty
         JSR C39A1C      ; Draw stat preview
         JSR C371A9      ; Blank item list
         JSR C313D3      ; Refresh screen
         JMP C3A49B      ; Draw item list

; Fork: Handle B
C3A0A3:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A0B7      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JSR C395C5      ; Load navig data
         JSR C395CE      ; Relocate cursor
         LDA #$36        ; C3/9E10
         STA $26         ; Next: Option list
         RTS

; Fork: Handle L and R, prepare for menu reset
C3A0B7:  LDA #$7E        ; C3/1C4B
         STA $E0         ; Set init command
         JMP C32088      ; Handle L and R

; 56: Handle manual gear removal
C3A0BE:  JSR C395E7      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A0E3      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JSR C39BE1      ; Actor's address
         REP #$21        ; 16-bit A; C-
         TYA             ; Move it to A
         SEP #$20        ; 8-bit A
         ADC $4B         ; Add cursor slot
         TAY             ; Index sum
         LDA $001F,Y     ; Item in slot
         JSR C3A56C      ; Put in stock
         LDA #$FF        ; Empty item
         STA $001F,Y     ; Clear gear slot
         JSR C398C4      ; Redo text, status

; Fork: Handle B
C3A0E3:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A0F7      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JSR C395C5      ; Load navig data
         JSR C395CE      ; Relocate cursor
         LDA #$36        ; C3/9E10
         STA $26         ; Next: Option list
         RTS

; Fork: Handle L and R, prepare for menu reset
C3A0F7:  LDA #$7F        ; C3/1C59
         STA $E0         ; Set init command
         JMP C32088      ; Handle L and R

; 57: Handle gear browsing
C3A0FE:  JSR C3A2C2      ; Handle navigation
         JSR C39A1C      ; Draw stat preview
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A133      ; Branch if not
         JSR C3A231      ; On a gray item?
         BCC C3A15D      ; Fail if so
         JSR C30F1D      ; Sound: Click
         LDA $001F,Y     ; Item to unequip
         CMP #$FF        ; None?
         BEQ C3A11C      ; Branch if so
         JSR C3A56C      ; Put in stock
C3A11C:  TDC             ; Clear A
         LDA $4B         ; Gear list slot
         TAX             ; Index it
         LDA $7E9D8A,X   ; Inventory slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         STA $001F,Y     ; Equip on actor
         JSR C3A5A5      ; Adjust stock
         JSR C398C4      ; Redo text, status
         BRA C3A13C      ; Exit gear list

; Fork: Handle B
C3A133:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A15C      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C3A13C:  JSR C3A476      ; Clear stat preview
         REP #$20        ; 16-bit A
         LDA #$0100      ; BG1 H-Shift: 256
         STA $7E9BD0     ; Hide gear list
         SEP #$20        ; 8-bit A
         LDA #$C1        ; Top cursor: Off
         TRB $46         ; Scrollbar: Off
         JSR C395E1      ; Load navig data
         LDA $5F         ; Former position
         STA $4E         ; Set cursor row
         JSR C395EA      ; Relocate cursor
         LDA #$55        ; C3/A073
         STA $26         ; Next: Body parts
C3A15C:  RTS

; Fork: Invalid selection
C3A15D:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
         RTS

; Draw "R-hand" and "L-hand" in Equip menu
C3A164:  LDA $11D8       ; Gear effects
         AND #$08        ; Gauntlet?
         BEQ C3A17E      ; Branch if not
         JSR C39BE1      ; Define Y
         LDA $001F,Y     ; R-Hand item
         CMP #$FF        ; None?
         BEQ C3A195      ; Branch if so
         LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; None?
         BEQ C3A1B9      ; Branch if so
         BRA C3A17E      ; ...

; Fork: Draw both hands in blue
C3A17E:  LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         JSR C3A187      ; Draw "R-hand"
         BRA C3A18E      ; Draw "L-hand"

; Sub: Draw "R-hand"
C3A187:  LDY #C3AAC8     ; Text pointer
         JSR C30326      ; Draw "R-hand"
         RTS

; Sub: Draw "L-hand"
C3A18E:  LDY #C3AACE     ; Text pointer
         JSR C30326      ; Draw "L-hand"
         RTS

; Fork: Check if L-Hand also empty
C3A195:  LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; None?
         BNE C3A19E      ; Branch if not
         BRA C3A17E      ; Draw both in blue

; Fork: Check if two-handed weapon in L-Hand
C3A19E:  JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85013,X   ; Properties
         AND #$40        ; 2-hand OK?
         BEQ C3A17E      ; Blue x2 if not
         LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         JSR C3A187      ; Draw "R-hand"
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         BRA C3A18E      ; Draw "L-hand"

; Fork: Check if two-handed weapon in R-Hand
C3A1B9:  LDA $001F,Y     ; R-Hand item
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85013,X   ; Properties
         AND #$40        ; 2-hand OK?
         BEQ C3A17E      ; Blue x2 if not
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         JSR C3A187      ; Draw "R-hand"
         LDA #$24        ; Palette 1
         STA $29         ; Color: Gray
         BRA C3A18E      ; Draw "L-hand"

; Define Bat.Pwr mode (normal, doubled, or combined hands)
C3A1D7:  STZ $CD         ; Genji mode off
         LDA $11D8       ; Gear effects
         AND #$10        ; Genji Glove?
         BEQ C3A1E2      ; Branch if not
         INC $CD         ; Pwr: Merge hands
C3A1E2:  STZ $A1         ; Power x2: Off
         LDA $11D8       ; Gear effects
         AND #$08        ; Gauntlet?
         BEQ C3A1FB      ; Exit if not
         LDA $001F,Y     ; R-Hand item
         CMP #$FF        ; None?
         BEQ C3A1FD      ; Branch if so
         LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; None?
         BEQ C3A21A      ; Branch if so
         BRA C3A1FB      ; ...
C3A1FB:  SEC             ; ...
         RTS

; Fork: Check if L-Hand also empty
C3A1FD:  LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; None?
         BNE C3A206      ; Branch if not
         BRA C3A1FB      ; Exit

; Fork: Check if two-handed weapon in L-Hand
C3A206:  JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85013,X   ; Properties
         AND #$40        ; 2-hand OK?
         BEQ C3A1FB      ; Exit if not
         CLC             ; ...
         LDA #$01        ; Power: x2
         STA $A1         ; Set Pwr mode
         RTS

; Fork: Check if two-handed weapon in R-Hand
C3A21A:  LDA $001F,Y     ; R-Hand item
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85013,X   ; Properties
         AND #$40        ; 2-hand OK?
         BEQ C3A1FB      ; Exit if not
         CLC             ; ...
         LDA #$01        ; Power: x2
         STA $A1         ; Set Pwr mode
         RTS

; Check if pointing at grayed out gear
C3A231:  JSR C3A239      ; Actor address
         TDC             ; Clear A
         LDA $4B         ; Gear list slot
         BRA C3A245      ; Analyze item

; Load address to selected body slot
C3A239:  JSR C39BE1      ; Actor's address
         REP #$21        ; 16-bit A; C-
         TYA             ; Move it to A
         SEP #$20        ; 8-bit A
         ADC $5F         ; Add body slot
         TAY             ; Move it to Y
         RTS

; Determine whether gear list entry is disabled
C3A245:  PHY             ; ...
         TAX             ; Gear list slot
         LDA $7E9D8A,X   ; Inventory slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         STA $F6         ; Memorize it
         PLY             ; ...
         LDA $5F         ; Body slot
         CMP #$02        ; Head or body?
         BCS C3A2BE      ; Enable if so
         CMP #$01        ; L-Hand/relic 2?
         BEQ C3A294      ; Branch if so

; Fork: For R-Hand or relic 1
C3A268:  LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; None?
         BEQ C3A286      ; Enable if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$03        ; Shield?
         BEQ C3A288      ; Branch if so
         LDA $11D8       ; Gear effects
         AND #$10        ; Genji Glove?
         BEQ C3A288      ; Branch if not
C3A286:  SEC             ; Set to enable
         RTS

; Fork: Prevent two shields or weapons
C3A288:  LDA $D85000,X   ; L-Hand's specs
         AND #$07        ; Get item class
         CMP $F6         ; Like list item?
         BEQ C3A2C0      ; Disable if so
         SEC             ; Set to enable
         RTS

; Fork: For L-Hand or relic 2
C3A294:  LDA $001E,Y     ; R-Hand item
         CMP #$FF        ; None?
         BEQ C3A2B2      ; Enable if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$03        ; Shield?
         BEQ C3A2B4      ; Branch if so
         LDA $11D8       ; Gear effects
         AND #$10        ; Genji Glove?
         BEQ C3A2B4      ; Branch if not
C3A2B2:  SEC             ; Set to enable
         RTS

; Fork: Prevent two shields or weapons
C3A2B4:  LDA $D85000,X   ; R-Hand's specs
         AND #$07        ; Get item class
         CMP $F6         ; Like list item?
         BEQ C3A2C0      ; Disable if so
C3A2BE:  SEC             ; Set to enable
         RTS

; Fork: Disable listed item
C3A2C0:  CLC             ; Set to disable
         RTS

; Handle D-Pad plus L and R for gear browsing
C3A2C2:  LDA $7E9D89     ; List size
         CMP #$0A        ; Over 9 items?
         BCS C3A2CD      ; Branch if so
         JMP C39612      ; Handle D-Pad

; Fork: Scrollable list
C3A2CD:  LDA #$05        ; List type: Gear
         STA $2A         ; Set redraw mode
         JSR C31FCA      ; Handle L and R
         BCS C3A2D9      ; Exit if pushed
         JMP C39603      ; Handle D-Pad
C3A2D9:  RTS

; Initialize cursor data for list of available gear
C3A2DA:  LDA $7E9D89     ; Number of items
         BEQ C3A2FB      ; Exit if none
         CMP #$0A        ; Over 9?
         BCS C3A2F5      ; Branch if so
         JSR C3A5D2      ; Duplicate cursor
         STZ $4A         ; List scroll: 0
         JSR C3960C      ; Load navig data
         LDA $7E9D89     ; Number of items
         STA $54         ; Set cursor limit
         JMP C39615      ; Relocate cursor

; Fork: Scrollable list
C3A2F5:  JSR C3A5D2      ; Duplicate cursor
         JSR C3A2FC      ; Move cursor; bar
C3A2FB:  RTS

; Initialize cursor data for scrollable gear list
C3A2FC:  STZ $4A         ; List scroll: 0
         JSR C309B8      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$0060      ; Y: 96
         STA $7E34CA,X   ; Set scrollbar's
         LDA #$6000      ; Bar range: 60 px
         STA $4204       ; Set dividend
         SEP #$20        ; 8-bit A
         LDA $7E9D89     ; Number of items
         SEC             ; Prepare SBC
         SBC #$09        ; Deduct page size
         STA $4206       ; Set divisor
         NOP
         NOP
         NOP
         NOP
         NOP
         REP #$20        ; 16-bit A
         LDA $4214       ; Quotient
         STA $7E354A,X   ; Set bar's V-Spd
         SEP #$20        ; 8-bit A
         LDY $00         ; Clear Y
         STY $4F         ; List col/row: 1
         JSR C395FD      ; Load navig data
         JSR C39606      ; Relocate cursor
         LDA $7E9D89     ; Number of items
         SEC             ; Prepare SBC
         SBC #$09        ; Deduct page size
         STA $5C         ; Set scroll limit
         LDA #$09        ; Onscreen rows: 9
         STA $5A         ; Set rows per page
         LDA #$01        ; Onscreen cols: 1
         STA $5B         ; Set cols per page
         RTS

; Compile compatible gear for actor's body part
C3A348:  JSR C3A419      ; Init list
         JSR C3A430      ; Define compat
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDA $4B         ; Body part
         CMP #$02        ; Head?
         BEQ C3A3A1      ; Branch if so
         CMP #$03        ; Armor?
         BEQ C3A35E      ; Branch if so
         BRA C3A361      ; Handle hands
C3A35E:  JMP C3A3DD      ; Handle torso

; Fork: Weapons and shields
C3A361:  LDX $00         ; Clear X...
         TXY             ; Item slot: 1
C3A364:  TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3A392      ; Skip if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$01        ; Weapon?
         BEQ C3A380      ; Branch if so
         CMP #$03        ; Shield?
         BNE C3A392      ; Skip if not
C3A380:  REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         BIT $E7         ; Actor can use?
         BEQ C3A392      ; Skip if not
         SEP #$20        ; 8-bit A
         TYA             ; Item slot
         STA $2180       ; Add to list
         INC $E0         ; List size +1
C3A392:  SEP #$20        ; 8-bit A
         INY             ; Item slot +1
         CPY #$00FF      ; Done 255?...
         BNE C3A364      ; Loop if not
         LDA $E0         ; List size
         STA $7E9D89     ; Save to list
         RTS

; Fork: Helmet list
C3A3A1:  LDX $00         ; Clear X...
         TXY             ; Item slot: 1
C3A3A4:  TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3A3CE      ; Skip if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$04        ; Helmet?
         BNE C3A3CE      ; Skip if not
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         BIT $E7         ; Actor can use?
         BEQ C3A3CE      ; Skip if not
         SEP #$20        ; 8-bit A
         TYA             ; Item slot
         STA $2180       ; Add to list
         INC $E0         ; List size +1
C3A3CE:  SEP #$20        ; 8-bit A
         INY             ; Item slot +1
         CPY #$00FF      ; Done 255?...
         BNE C3A3A4      ; Loop if not
         LDA $E0         ; List size
         STA $7E9D89     ; Save to list
         RTS

; Fork: Armor list
C3A3DD:  LDX $00         ; Clear X...
         TXY             ; Item slot: 1
C3A3E0:  TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3A40A      ; Skip if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$02        ; Armor?
         BNE C3A40A      ; Skip if not
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         BIT $E7         ; Actor can use?
         BEQ C3A40A      ; Skip if not
         SEP #$20        ; 8-bit A
         TYA             ; Item slot
         STA $2180       ; Add to list
         INC $E0         ; List size +1
C3A40A:  SEP #$20        ; 8-bit A
         INY             ; Item slot +1
         CPY #$00FF      ; Done 255?...
         BNE C3A3E0      ; Loop if not
         LDA $E0         ; List size
         STA $7E9D89     ; Save to list
         RTS

; Initialize list of compatible gear
C3A419:  LDX $00         ; Index: 0
         LDA #$FF        ; Item slot 256
C3A41D:  STA $7E9D8A,X   ; Add to list
         INX             ; Index +1
         CPX #$0009      ; Done 9 times?
         BNE C3A41D      ; Loop if not
         LDX #$9D8A      ; 7E/9D8A
         STX $2181       ; Set WRAM LBs
         STZ $E0         ; List size: 0
         RTS

; Defaulting to item slot 256, which was likely inaccessible at some point during		=== SNES: Different implications as item slot 256 is inaccessible
; development, provides a fallback for Optimum in case the list is empty or contains
; only banned items such as Cursed Shld. This introduces a bug that allows anything
; to be equipped on a given body part.


; Define gear compatibility for actor
C3A430:  JSR C39BE1      ; Define Y
         TDC             ; ...
         LDA $0000,Y     ; Actor
C3A437:  ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3A456,X  ; Compat bit
         STA $E7         ; Memorize it
         SEP #$20        ; 8-bit A
         LDA $11D8       ; Gear effects
         AND #$20        ; Merit Award?
         BEQ C3A455      ; Exit if not
         REP #$20        ; 16-bit A
         LDA $E7         ; Actor's bit
         ORA #$8000      ; Add award's
         STA $E7         ; Save changes
         SEP #$20        ; 8-bit A
C3A455:  RTS

; Bitfield for actor slots
C3A456:  dw $0001        ; Terra
         dw $0002        ; Locke
         dw $0004        ; Cyan
         dw $0008        ; Shadow
         dw $0010        ; Edgar
         dw $0020        ; Sabin
         dw $0040        ; Celes
         dw $0080        ; Strago
         dw $0100        ; Relm
         dw $0200        ; Setzer
         dw $0400        ; Mog
         dw $0800        ; Gau
         dw $1000        ; Gogo
         dw $2000        ; Umaro
         dw $4000        ; Guest 1
         dw $8000        ; Guest 2

; Erase projected stats in Equip or Relic menu
C3A476:  TDC             ; Clear A
         TAX             ; 1st: Vigor
         LDY #$0009      ; Stats: 9
         REP #$20        ; 16-bit A
C3A47D:  STA $7E7CBF,X   ; Clear hundreds
         INX             ; Index +1
         INX             ; Index +1
         STA $7E7CBF,X   ; Clear tens
         INX             ; Index +1
         INX             ; Index +1
         STA $7E7CBF,X   ; Clear ones
         INX             ; Index +1
         INX             ; Index +1
         TXA             ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$007A      ; Row +2, col -3
         TAX             ; Reindex it
         DEY             ; One less stat
         BNE C3A47D      ; Loop till last
         SEP #$20        ; 8-bit A
         RTS

; Draw and reveal list of available gear for body part
C3A49B:  LDA $7E9D89     ; Empty list?
         BEQ C3A4CC      ; Abort if so
         JSR C38B78      ; Define $E5, $E6
         TDC             ; Clear A
         LDA $7E9D89     ; List size
         CMP #$09        ; Over 8 items?
         BCC C3A4AF      ; Branch if not
         LDA #$09        ; Rows left: 9
C3A4AF:  TAY             ; Put in Y...
C3A4B0:  PHY             ; Memorize it
         JSR C3A4D1      ; Draw item name
         INC $E5         ; List slot +1
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         INC A           ; Go 1 row down
         AND #$1F        ; Stay in limits
         STA $E6         ; Save changes
         PLY             ; Rows left
         DEY             ; One less left
         BNE C3A4B0      ; Loop till last
         REP #$20        ; 16-bit A
         TDC             ; BG1 H-Shift: 0
         STA $7E9BD0     ; Unhide gear list
         SEP #$20        ; 8-bit A
         RTS             ; Exit
C3A4CC:  LDA $27         ; Old menu mode
         STA $26         ; Set as current
         RTS

; Draw item's name and quantity for list of available gear	=== SNES: No quantity
C3A4D1:  JSR C3A239      ; Actor's address
         TDC             ; Clear A
         LDA $E5         ; Gear list slot
         JSR C3A245      ; Gray out item?
         BCS C3A4E0      ; Branch if not
         LDA #$28        ; Color: Gray
         BRA C3A4E2      ; Skip a line
C3A4E0:  LDA #$20        ; Color: User's
C3A4E2:  STA $29         ; Set palette
         TDC             ; Clear A				%%%
         LDA $E5         ; Gear list slot
         TAX             ; Index it
         LDA $7E9D8A,X   ; Inventory slot
         TAY             ; Index it
         LDA $1969,Y     ; Item quantity
         JSR C30563      ; Turn into text
         LDA $E6         ; BG1 write row
         INC A           ; Go 1 row down
         LDX #$000C      ; X: 12
         JSR C38820      ; Compute map ptr
         JSR C30539      ; Draw 2 digits
         LDA $E6         ; BG1 write row

         LDX #$0002      ; X: 2
         JSR C38820      ; Compute map ptr
         REP #$20        ; 16-bit A
         TXA             ; ...
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $E5         ; Gear list slot
         TAY             ; Put it in Y
         JSR C3A51A      ; Load "<item>:"			=== SNES: No colon
         JMP C387B9      ; Draw "<item>:"

; Load name of item from list of available gear, add a colon	=== SNES: No colon as quantity isn't listed
C3A51A:  LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
C3A520:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C3A520      ; Loop if not
         TYX             ; Gear list slot
         TDC             ; ...
         LDA $7E9D8A,X   ; Inventory slot
         TAY             ; Index it
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3A55D      ; Blank if so
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$09        ; Name data size		=== SNES: 13
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDX $2134       ; Index product
         LDY #$0009      ; Letters: 9			=== SNES: 13
C3A549:  LDA $E6F700,X   ; Letter			=== SNES: $D2B300
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C3A549      ; Loop till last
         LDA #$CF        ; Char: ":"			%%%
         STA $2180       ; Add to string
         STZ $2180       ; End string
         RTS

; Fork: Blank item slot
C3A55D:  LDY #$000C      ; Spaces: 12			=== SNES: 13
         LDA #$FF        ; Space char
C3A562:  STA $2180       ; Add to string
         DEY             ; One less left
         BNE C3A562      ; Loop till last
         STZ $2180       ; End string
         RTS

; Add item to inventory
C3A56C:  PHY             ; Save Y
         STA $E0         ; Set item to add
         LDY $00         ; Item slot: 1
C3A571:  CMP $1869,Y     ; Slot holds it?
         BEQ C3A598      ; Qty +1 if so
         CMP #$FF        ; Empty item?
         BEQ C3A5A3      ; Exit if so
         INY             ; Item slot +1
         CPY #$0100      ; Done all 256?
         BNE C3A571      ; Loop if not

; Fork: Find an empty slot
C3A580:  LDY $00         ; Item slot: 1
C3A582:  LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3A58C      ; Replace if so
         INY             ; Item slot +1
         BRA C3A582      ; Try next slot

; Fork: Put item in empty slot
C3A58C:  LDA #$01        ; Quantity: 1
         STA $1969,Y     ; Assign to slot
         LDA $E0         ; Item to add
         STA $1869,Y     ; Put in slot
         BRA C3A5A3      ; Exit

; Fork: Quantity +1
C3A598:  LDA $1969,Y     ; Quantity owned
         CMP #$63        ; 99?
         BEQ C3A5A3      ; Exit if so
         INC A           ; Quantity +1
         STA $1969,Y     ; Save changes
C3A5A3:  PLY             ; Restore Y
         RTS

; Remove item from inventory
C3A5A5:  PHY             ; Save Y
         STA $E0         ; ...
         LDY $00         ; Item slot: 1
C3A5AA:  CMP $1869,Y     ; Slot holds it?
         BEQ C3A5B7      ; Branch if so
         INY             ; Item slot +1
         CPY #$0100      ; Done all 256?
         BNE C3A5AA      ; Loop if not
         PLY             ; Restore Y
         RTS

; Fork: Quantity -1
C3A5B7:  LDA $1969,Y     ; Quantity
         CMP #$01        ; One?
         BEQ C3A5C7      ; Delete if so
         LDA $1969,Y     ; ...
         DEC A           ; Quantity -1
         STA $1969,Y     ; Save changes
         BRA C3A5D0      ; Exit

; Fork: Clear item slot
C3A5C7:  TDC             ; Clear A
         STA $1969,Y     ; Quantity: 0
         LDA #$FF        ; Empty item
         STA $1869,Y     ; Put in slot
C3A5D0:  PLY             ; Restore Y
         RTS

; Duplicate cursor before browsing gear
C3A5D2:  LDA #$02        ; Min slot: 16
         LDY #C3A5EB     ; C3/A5EB
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA $55         ; Cursor's X
         STA $7E33CA,X   ; Set dupe's
         LDA $57         ; Cursor's Y
         STA $7E344A,X   ; Set dupe's
         SEP #$20        ; 8-bit A
         RTS

; Update cursor indicating selected gear slot
C3A5EB:  TAX             ; Index mode
         JMP (C3A5EF,X)  ; Handle mode

; Jump table for the above
C3A5EF:  dw C3A5F3       ; Initialize cursor
         dw C3A60E       ; Sustain cursor

; Mode 0: Initialize cursor
C3A5F3:  LDX $2D         ; Queue index
         LDA #$01        ; Dupe: Sustain
         TSB $46         ; Set menu flag
         REP #$20        ; 16-bit A
         LDA #C30912     ; Anim table ptr
         STA $32C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         INC $3649,X     ; Mode +1

; Mode 1: Sustain cursor
C3A60E:  LDA $46         ; Menu flags
         BIT #$01        ; Remove dupe?
         BEQ C3A61B      ; Delete if so
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C3A61B:  CLC             ; Set to dequeue
         RTS

; Set to upload text tilemaps for Equip menu
C3A61D:  JSR C3A631      ; Queue BG3 upload
         BRA C3A645      ; Queue BG1 upload

; Set to upload text tilemaps for Relic menu
C3A622:  JSR C3A645      ; Queue BG1 upload
         LDA $021E       ; Frame counter
         AND #$01        ; Odd value?
         BEQ C3A62E      ; Favor desc if so
         BRA C3A631      ; Queue stats upload
C3A62E:  JMP C3B301      ; Queue desc upload

; Set to upload BG3 tilemaps A and upper B
C3A631:  LDY #$4000      ; $4000
         STY $1B         ; Set VRAM ptr
         LDY #$7849      ; 7E/7849
         STY $1D         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         LDY #$0880      ; Bytes: 2176
         STY $19         ; Set data size
         RTS

; Set to upload BG1 tilemap A
C3A645:  LDY #$0000      ; $0000
         STY $14         ; Set VRAM ptr
         LDY #$3849      ; 7E/3849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $12         ; Set data size
         RTS

; 58: Initialize Relic menu
C3A659:  JSR C3A65E      ; Init variables
         BRA C3A67D      ; Draw menu, etc.

; Initialize variables for Relic menu
C3A65E:  JSR C335F7      ; Reset/Stop stuff
         JSR C3719C      ; Set Win1 bounds
         STZ $4A         ; List scroll: 0
         STZ $49         ; Top BG1 WR row: 1
         LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         STZ $99         ; Unmark Reequip
         JSR C31BFF      ; Queue desc anim
         JSR C39CA5      ; Set to shift text
         JSR C39632      ; Load navig data
         JSR C3963B      ; Relocate cursor
         JMP C30833      ; Queue cursor OAM

; Draw Relic menu, memorize original relics, etc.
C3A67D:  JSR C39813      ; Draw menu, etc.
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         LDA #$59        ; C3/A6C6
         STA $27         ; Queue: Option list
         JMP C33609      ; BRT:1 + NMI

; 79: Swap actor in Relic menu, retain Equip mode
C3A68B:  JSR C3A6A7      ; Draw menu, etc.
         JSR C39E3E      ; Draw blue "EQUIP"
         JSR C3A6B6      ; Cursor & Fade-in
         LDA #$5A        ; C3/A80B
         JMP C3A6C1      ; Queue: Slot list

; 7A: Swap actor in Relic menu, retain Remove mode
C3A699:  JSR C3A6A7      ; Draw menu, etc.
         JSR C39E45      ; Draw blue "REMOVE"
         JSR C3A6B6      ; Cursor & Fade-in
         LDA #$5C        ; C3/A918
         JMP C3A6C1      ; Queue: Slot list

; Reset Relic menu for either of the above
C3A6A7:  JSR C3A65E      ; Init variables
         JSR C39813      ; Draw menu, etc.
         JSR C3A645      ; Queue BG1 upload
         JSR C3A631      ; Queue BG3 upload
         JMP C39E03      ; Switch windows

; Put cursor on first relic slot, trigger fade-in
C3A6B6:  JSR C3964A      ; Load navig data
         JSR C39653      ; Relocate cursor
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         RTS

; Queue Equip or Remove mode after actor swap in Relic menu
C3A6C1:  STA $27         ; Set queued command
         JMP C33609      ; BRT:1 + NMI

; 59: Handle Relic menu options
C3A6C6:  JSR C3A631      ; Queue BG3 upload
         JSR C39DFB      ; Switch windows
         JSR C39805      ; Draw options
         JSR C39638      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A6DE      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JMP C3A7DD      ; Handle choice

; Fork: Handle B
C3A6DE:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A6EA      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JSR C3A6F9      ; Handle Reequip

; Fork: Handle L and R, prepare for menu reset
C3A6EA:  JSR C3A6F4      ; Plan Reequip pos
         LDA #$58        ; C3/A659
         STA $E0         ; Set init command
         JMP C32088      ; Handle L and R

; Memorize menu mode for positioning Reequip warning
C3A6F4:  LDA $26         ; Menu mode
         STA $D1         ; Save for Reequip
         RTS

; Test Reequip activation, select menu commands accordingly
C3A6F9:  JSR C398B9      ; Get gear effects
         JSR C39BE1      ; Define Y
         LDA $0000,Y     ; Actor
         CMP #$0D        ; Umaro?
         BEQ C3A70D      ; Branch if so
         JSR C3A76A      ; Test Reequip
         LDA $99         ; Triggered it?
         BNE C3A714      ; Branch if so
C3A70D:  LDA #$04        ; C3/1AF0
         STA $27         ; Queue main menu
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Triggered Reequip
C3A714:  LDA #$06        ; Main cursor: Off
         TRB $46         ; Set menu flag
         JSR C3A645      ; Queue BG1 upload
         JSR C3A631      ; Queue BG3 upload
         JSR C3A72A      ; Handle text, etc.
         LDA #$F0        ; Frames: 240
         STA $22         ; Set fade delay
         LDA #$6C        ; C3/A7BF
         STA $26         ; Next: Late fade
         RTS

; Handle Reequip activation
C3A72A:  JSR C39E4C      ; Erase top text
         LDY #C3AC33     ; Text pointer
         JSR C30326      ; Draw warning
         LDA $1D4E       ; Game options
         AND #$10        ; Optimum mode?
         BEQ C3A752      ; Branch if so

; Fork: Empty mode
C3A73A:  LDA #$6E        ; C3/1C8C
         STA $27         ; Queue removal
         LDA $D1         ; Menu mode
         CMP #$59        ; Relic options?
         BEQ C3A74B      ; Branch if so
         LDY #C3AC1B     ; Text pointer
         JSR C30326      ; Draw "Empty"
         RTS

; Fork: Draw "Empty" in option window
C3A74B:  LDY #C3AC03     ; Text pointer
         JSR C30326      ; Draw "Empty"
         RTS

; Fork: Optimum mode
C3A752:  LDA #$6D        ; C3/1C80
         STA $27         ; Queue optimizing
         LDA $D1         ; Menu mode
         CMP #$59        ; Relic options?
         BEQ C3A763      ; Branch if so
         LDY #C3AC26     ; Text pointer
         JSR C30326      ; Draw "Optimum"
         RTS

; Fork: Draw "Optimum" in option window
C3A763:  LDY #C3AC0E     ; Text pointer
         JSR C30326      ; Draw "Optimum"
         RTS

; Determine whether to trigger Reequip in Relic menu
C3A76A:  JSR C39BE1      ; Define Y...
         LDA $0023,Y     ; Relic 1
         CMP $B0         ; Unchanged?
         BNE C3A77D      ; Branch if not
         LDA $0024,Y     ; Relic 2
         CMP $B1         ; Unchanged?
         BNE C3A77D      ; Branch if not
         BRA C3A7B7      ; Reequip: No

; Fork: Compare old and new relics
C3A77D:  LDA $B0         ; Old relic 1
         CMP #$D1        ; Genji Glove?
         BEQ C3A7BA      ; Trigger if so
         CMP #$D0        ; Gauntlet?
         BEQ C3A7BA      ; Trigger if so
         CMP #$DA        ; Merit Award?
         BEQ C3A7BA      ; Trigger if so
         LDA $B1         ; Old relic 2
         CMP #$D1        ; Genji Glove?
         BEQ C3A7BA      ; Trigger if so
         CMP #$D0        ; Gauntlet?
         BEQ C3A7BA      ; Trigger if so
         CMP #$DA        ; Merit Award?
         BEQ C3A7BA      ; Trigger if so
         LDA $0023,Y     ; Relic 1
         CMP #$D1        ; Genji Glove?
         BEQ C3A7BA      ; Trigger if so
         CMP #$D0        ; Gauntlet?
         BEQ C3A7BA      ; Trigger if so
         CMP #$DA        ; Merit Award?
         BEQ C3A7BA      ; Trigger if so
         LDA $0024,Y     ; Relic 2
         CMP #$D1        ; Genji Glove?
         BEQ C3A7BA      ; Trigger if so
         CMP #$D0        ; Gauntlet?
         BEQ C3A7BA      ; Trigger if so
         CMP #$DA        ; Merit Award?
         BEQ C3A7BA      ; Trigger if so
C3A7B7:  STZ $99         ; Reequip: No
         RTS

; Fork: Set to open Equip menu
C3A7BA:  LDA #$01        ; Reequip: Yes
         STA $99         ; Set indicator
         RTS

; 6C: Handle delayed fade-out for Reequip
C3A7BF:  LDA $22         ; Delay expired?
         BNE C3A7C6      ; Branch if not
         STZ $26         ; Next: Fade-out
         RTS             ; Exit
C3A7C6:  DEC $22         ; Timer -1
         LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BNE C3A7DA      ; Fade if so
         LDA $08         ; ...
         BIT #$20        ; Pushing L?
         BNE C3A7DA      ; Fade if so
         LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A7DC      ; Exit if not
C3A7DA:  STZ $26         ; Next: Fade-out
C3A7DC:  RTS

; Handle selected option in Relic menu
C3A7DD:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C3A7E5,X)  ; Handle option

; Jump table for the above
C3A7E5:  dw C3A7E9       ; EQUIP
         dw C3A7FA       ; REMOVE

; Handle "EQUIP" selection in Relic menu
C3A7E9:  JSR C39E03      ; Switch windows
         JSR C39E3E      ; Draw blue "EQUIP"
         JSR C3964A      ; Load navig data
         JSR C39653      ; Relocate cursor
         LDA #$5A        ; C3/A80B
         STA $26         ; Next: Slot list
         RTS

; Handle "REMOVE" selection in Relic menu
C3A7FA:  JSR C39E03      ; Switch windows
         JSR C39E45      ; Draw blue "REMOVE"
         JSR C3964A      ; Load navig data
         JSR C39653      ; Relocate cursor
         LDA #$5C        ; C3/A918
         STA $26         ; Next: Slot list
         RTS

; 5A: Handle selection of relic slot to fill
C3A80B:  JSR C3A622      ; Queue text upload
         JSR C39650      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A841      ; Branch if not
         JSR C30F1D      ; Sound: Click
         LDA $4E         ; Cursor row
         STA $5F         ; Set body slot
         LDA #$5B        ; C3/A8A5
         STA $26         ; Next: Relic list
         JSR C3A85F      ; Get valid items
         JSR C3A95E      ; Sort by Defense
         JSR C3A2DA      ; Cursor & Scrollbar
         LDA #$5A        ; Return here if..
         STA $27         ; ..list is empty
         JSR C371A9      ; Clear BG1 map A
         JSR C313D3      ; Refresh screen
         JSR C3A49B      ; Draw item list
         JSR C39A1C      ; Draw stat preview
         JSR C3A631      ; Queue BG3 upload
         JMP C313D3      ; Refresh screen

; Fork: Handle B
C3A841:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A855      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JSR C39632      ; Load navig data
         JSR C3963B      ; Relocate cursor
         LDA #$59        ; C3/A6C6
         STA $26         ; Next: Option list
         RTS

; Fork: Handle L and R, prepare for menu reset
C3A855:  JSR C3A6F4      ; Plan Reequip pos
         LDA #$79        ; C3/A68B
         STA $E0         ; Set init command
         JMP C32088      ; Handle L and R

; Compile compatible relics
C3A85F:  JSR C3A419      ; Init list
         JSR C3A430      ; Define compat
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX $00         ; Clear X...
         TXY             ; Item slot: 1
C3A86C:  TDC             ; Clear A
         LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3A896      ; Skip if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$05        ; Relic?
         BNE C3A896      ; Skip if not
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         BIT $E7         ; Actor can use?
         BEQ C3A896      ; Skip if not
         SEP #$20        ; 8-bit A
         TYA             ; Item slot
         STA $2180       ; Add to list
         INC $E0         ; List size +1
C3A896:  SEP #$20        ; 8-bit A
         INY             ; Item slot +1
         CPY #$00FF      ; Done 255?...			=== SNES checks 256 but pointless in that version
         BNE C3A86C      ; Loop if not
         LDA $E0         ; List size
         STA $7E9D89     ; Save to list
         RTS

; 5B: Handle relic browsing
C3A8A5:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         JSR C3A622      ; Queue text upload
         JSR C3A2C2      ; Handle navigation
         JSR C39A1C      ; Draw stat preview
         JSR C3A9E6      ; Load description

; Fork: Handle A
C3A8B5:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A8EA      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JSR C39BE1      ; Actor's address
         REP #$21        ; 16-bit A; C-
         TYA             ; Move it to A
         SEP #$20        ; 8-bit A
         ADC $5F         ; Add relic slot
         TAY             ; Index sum
         LDA $0023,Y     ; Relic to unequip
         CMP #$FF        ; None?
         BEQ C3A8D3      ; Branch if so
         JSR C3A56C      ; Put in stock
C3A8D3:  TDC             ; Clear A
         LDA $4B         ; Gear list slot
         TAX             ; Index it
         LDA $7E9D8A,X   ; Inventory slot
         TAX             ; Index it
         LDA $1869,X     ; Selected item
         STA $0023,Y     ; Equip on actor
         JSR C3A5A5      ; Reduce stock
         JSR C398DA      ; Draw info; status
         BRA C3A8F3      ; Exit list

; Fork: Handle B
C3A8EA:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A917      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C3A8F3:  LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         JSR C3A476      ; Clear stat preview
         REP #$20        ; 16-bit A
         LDA #$0100      ; BG1 H-Shift: 256
         STA $7E9BD0     ; Hide gear list
         SEP #$20        ; 8-bit A
         LDA #$C1        ; Top cursor: Off
         TRB $46         ; Scrollbar: Off
         JSR C3964A      ; Load navig data
         LDA $5F         ; Former position
         STA $4E         ; Set cursor row
         JSR C39653      ; Relocate cursor
         LDA #$5A        ; C3/A80B
         STA $26         ; Next: Slot list
C3A917:  RTS

; 5C: Handle relic removal
C3A918:  JSR C3A631      ; Queue BG3 upload
         JSR C39650      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3A940      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JSR C39BE1      ; Actor's address
         REP #$21        ; 16-bit A; C-
         TYA             ; Move it to A
         SEP #$20        ; 8-bit A
         ADC $4B         ; Add cursor slot
         TAY             ; Index sum
         LDA $0023,Y     ; Relic worn
         JSR C3A56C      ; Put in stock
         LDA #$FF        ; Empty item
         STA $0023,Y     ; Clear relic worn
         JSR C398DA      ; Draw info; status

; Fork: Handle B
C3A940:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3A954      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JSR C39632      ; Load navig data
         JSR C3963B      ; Relocate cursor
         LDA #$59        ; C3/A6C6
         STA $26         ; Next: Option list
         RTS

; Fork: Handle L and R, prepare for menu reset
C3A954:  JSR C3A6F4      ; Plan Reequip pos
         LDA #$7A        ; C3/A699
         STA $E0         ; Set init command
         JMP C32088      ; Handle L and R

; Sort compatible gear by power after loading power ratings
C3A95E:  LDX #$AC8D      ; 7E/AC8D
         STX $2181       ; Set WRAM LBs
         LDA $7E9D89     ; List size
         BEQ C3A994      ; Exit if 0
         CMP #$01        ; One item?
         BEQ C3A994      ; Exit if so
         STA $E7         ; Memorize it
         STZ $E8         ; Clear HB
         TDC             ; Clear A
         TAX             ; Gear slot: 1
         TAY             ; ...
C3A975:  LDA $7E9D8A,X   ; Inventory slot
         PHX             ; Save gear slot
         TAY             ; Index former
         LDA $1869,Y     ; Item in slot
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85014,X   ; Item's power
         STA $2180       ; Add to list
         PLX             ; Gear slot
         INX             ; Gear slot +1
         CPX $E7         ; End of list?
         BNE C3A975      ; Loop if not
         JSR C3A995      ; Sort list
C3A994:  RTS

; Sort list of compatible gear by power
C3A995:  DEC $E7         ; List size -1
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         TAY             ; Items done: 0
C3A99E:  TDC             ; Clear A
         TAX             ; List slot: 1
C3A9A0:  LDA $AC8D,X     ; Item's power
         CMP $AC8E,X     ; Next is worse?
         BCS C3A9C5      ; Skip if not
         STA $E0         ; Memorize it
         LDA $9D8A,X     ; Item number A
         STA $E1         ; Memorize it
         LDA $AC8E,X     ; Item power B
         STA $AC8D,X     ; Replace A's
         LDA $9D8B,X     ; Item number B
         STA $9D8A,X     ; Replace A's
         LDA $E0         ; Item power A
         STA $AC8E,X     ; Replace B's
         LDA $E1         ; Item number A
         STA $9D8B,X     ; Replace B's
C3A9C5:  INX             ; List slot +1
         CPX $E7         ; End of list?
         BNE C3A9A0      ; Loop if not
         INY             ; Items done +1
         CPY $E7         ; Fully sorted?
         BNE C3A99E      ; Loop if not
         PLB             ; Restore DB
         RTS

; Load item description for equipped relic (unused)
C3A9D1:  JSR C38A89      ; Set desc ptrs
         JSR C39BE1      ; Define Y
         LDA $4B         ; On "Relic 1"?
         BNE C3A9E0      ; Branch if not
         LDA $0023,Y     ; Relic 1
         BRA C3A9E3      ; Skip a line
C3A9E0:  LDA $0024,Y     ; Relic 2
C3A9E3:  JMP C35D95      ; Load description

; Load item description for relic browsing
C3A9E6:  JSR C38A89      ; Set desc ptrs
         TDC             ; Clear A
         LDA $4B         ; Gear list slot
         TAX             ; Index it
         LDA $7E9D8A,X   ; Inventory slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         JMP C35D95      ; Load description

; Text pointers for party gear overview
C3A9F8:  dw C3AA28       ; R-hand
         dw C3AA2D       ; L-hand
         dw C3AA33       ; Head
         dw C3AA39       ; Body
         dw C3AA3F       ; Relic 1
         dw C3AA45       ; Relic 2
C3AA04:  dw C3AA4B       ; R-hand
         dw C3AA50       ; L-hand
         dw C3AA56       ; Head
         dw C3AA5C       ; Body
         dw C3AA62       ; Relic 1
         dw C3AA68       ; Relic 2
C3AA10:  dw C3AA6E       ; R-hand
         dw C3AA73       ; L-hand
         dw C3AA79       ; Head
         dw C3AA7F       ; Body
         dw C3AA85       ; Relic 1
         dw C3AA8B       ; Relic 2
C3AA1C:  dw C3AA91       ; R-hand
         dw C3AA96       ; L-hand
         dw C3AA9C       ; Head
         dw C3AAA2       ; Body
         dw C3AAA8       ; Relic 1
         dw C3AAAE       ; Relic 2

; Positioned party gear overview text for member 1
C3AA28:  dw $394F : db |みぎ[end]|	; R-hand
C3AA2D:  dw $396B : db |ひだり[end]|	; L-hand
C3AA33:  dw $39CF : db |あたま[end]|	; Head
C3AA39:  dw $39EB : db |からだ[end]|	; Body
C3AA3F:  dw $3A4F : db |アク１[end]|	; Relic 1
C3AA45:  dw $3A6B : db |アク２[end]|	; Relic 2

; Positioned party gear overview text for member 2
C3AA4B:  dw $3B4F : db |みぎ[end]|	; R-hand
C3AA50:  dw $3B6B : db |ひだり[end]|	; L-hand
C3AA56:  dw $3BCF : db |あたま[end]|	; Head
C3AA5C:  dw $3BEB : db |からだ[end]|	; Body
C3AA62:  dw $3C4F : db |アク１[end]|	; Relic 1
C3AA68:  dw $3C6B : db |アク２[end]|	; Relic 2

; Positioned party gear overview text for member 3
C3AA6E:  dw $3D4F : db |みぎ[end]|	; R-hand
C3AA73:  dw $3D6B : db |ひだり[end]|	; L-hand
C3AA79:  dw $3DCF : db |あたま[end]|	; Head
C3AA7F:  dw $3DEB : db |からだ[end]|	; Body
C3AA85:  dw $3E4F : db |アク１[end]|	; Relic 1
C3AA8B:  dw $3E6B : db |アク２[end]|	; Relic 2

; Positioned party gear overview text for member 4
C3AA91:  dw $3F4F : db |みぎ[end]|	; R-hand
C3AA96:  dw $3F6B : db |ひだり[end]|	; L-hand
C3AA9C:  dw $3FCF : db |あたま[end]|	; Head
C3AAA2:  dw $3FEB : db |からだ[end]|	; Body
C3AAA8:  dw $404F : db |アク１[end]|	; Relic 1
C3AAAE:  dw $406B : db |アク２[end]|	; Relic 2

; Text pointers for Equip menu
C3AAB4:  dw C3AB1A       ; EQUIP
         dw C3AB20       ; OPTIMUM
         dw C3AB28       ; RMOVE
         dw C3AB2E       ; EMPTY
C3AABC:  dw C3AAD5       ; Head
         dw C3AADB       ; Body

; Text pointers for Relic menu
C3AAC0:  dw C3AB38       ; EQUIP
         dw C3AB3E       ; REMOVE
C3AAC4:  dw C3AAE1       ; Relic
         dw C3AAE9       ; Relic

; Positioned text for Equip and Relic menus			=== SNES: +40h as no diacritics
C3AAC8:  dw $79CD : db |みぎて[end]|	; R-hand
C3AACE:  dw $7A4D : db |ひだりて[end]|	; L-hand
C3AAD5:  dw $7ACD : db |あたま[end]|	; Head
C3AADB:  dw $7B4D : db |からだ[end]|	; Body
C3AAE1:  dw $7ACD : db |アクセサリ[end]|	; Relic
C3AAE9:  dw $7B4D : db |アクセサリ[end]|	; Relic

; Positioned spaces for blanking options and title in gear menus
C3AAF1:  dw $78D1 : db "                          ",$00		=== SNES has more; different position

; Positioned text for title in Equip and Relic menus		=== SNES: Positions differ
C3AB0E:  dw $78FD : db |そうび[end]|	; EQUIP
C3AB14:  dw $78FD : db |はずす[end]|	; REMOVE

; Positioned text for options in Equip menu			=== SNES: Positions differ
C3AB1A:  dw $78D1 : db |そうび[end]	|	; EQUIP
C3AB20:  dw $78DB : db |さいきょう[end]|	; OPTIMUM
C3AB28:  dw $78E9 : db |はずす[end]|	; RMOVE
C3AB2E:  dw $78F5 : db |すべてはずす [end]|	; EMPTY

; Positioned text for options in Relic menu
C3AB38:  dw $78D1 : db |そうび[end]|	; EQUIP			=== SNES: +40h as no diacritics
C3AB3E:  dw $78DB : db |はずす[end]|	; REMOVE		=== SNES: +40h as no diacritics; shifted rightward

; Text pointers for Equip and Relic menus
C3AB44:  dw C3AB68					; Vigor
         dw C3AB6E					; Stamina
         dw C3AB76					; Mag.Pwr
         dw C3AB7D					; Evade %
         dw C3AB85					; MBlock%
         dw C3AB90					; →
         dw C3AB94					; →
         dw C3AB98					; →
         dw C3AB9C					; →
         dw C3ABA0					; →
         dw C3ABA4					; →
         dw C3ABA8					; →
         dw C3ABAC					; →
         dw C3ABB0					; →
C3AB60:  dw C3ABB4					; Speed
         dw C3ABBB					; Bat.Pwr
         dw C3ABC5					; Defense
         dw C3ABCC					; Mag.Def

; Positioned text for Equip and Relic menus					=== SNES: Some positions differ
C3AB68:  dw $7CA7 : db |ちから[end]|			; Vigor
C3AB6E:  dw $7DA7 : db |たいりょく[end]|			; Stamina
C3AB76:  dw $7E27 : db |まりょく[end]|			; Mag.Pwr
C3AB7D:  dw $7FA7 : db |かいひりつ[end]|			; Evade %
C3AB85:  dw $80A7 : db |まほうかいひりつ[end]|			; MBlock%
C3AB90:  dw $7CBD : db |→[end]|
C3AB94:  dw $7D3D : db |→[end]|
C3AB98:  dw $7DBD : db |→[end]|
C3AB9C:  dw $7E3D : db |→[end]|
C3ABA0:  dw $7F3D : db |→[end]|
C3ABA4:  dw $7FBD : db |→[end]|
C3ABA8:  dw $7EBD : db |→[end]|
C3ABAC:  dw $803D : db |→[end]|
C3ABB0:  dw $80BD : db |→[end]|
C3ABB4:  dw $7CE7 : db |すばやさ[end]|			; Speed
C3ABBB:  dw $7E67 : db |こうげきりょく[end]|			; Bat.Pwr
C3ABC5:  dw $7EE7 : db |ぼうぎょ[end]|			; Defense
C3ABCC:  dw $7FE7 : db |まほうぼうぎょ[end]|			; Mag.Def
C3ABD6:  dw $79F3 : db "      ",$00  			; Blank effect A	%%%
C3ABDF:  dw $7A73 : db "      ",$00  			; Blank effect B
C3ABE8:  dw $7A6F : db |じゅうそうび[end]|			; Heavy gear
C3ABF1:  dw $79EF : db |にとうりゅう[end]|			; Dual wield
C3ABFA:  dw $7A6F : db |りょうてもち[end]|			; Two-handed
C3AC03:  dw $78E1 : db |「すべてはずす」[end]|			; Empty
C3AC0E:  dw $78E1 : db |「さいきょうそうび」[end]|			; Optimum
C3AC1B:  dw $7961 : db |「すべてはずす」[end]|			; Empty
C3AC26:  dw $7961 : db |「さいきょうそうび」[end]|			; Optimum
C3AC33:  dw $79CF : db |そうびにかかわるアクセサリーが へんこうされました[end]|	; Equipment changed.

; Establish button purposes and autofire delays
C3AC4F:  LDA #$08        ; Initial delay
         STA $0229       ; For: General
         LDA #$03        ; Repeat delay
         STA $022A       ; For: General
         STA $0226       ; For: A in battle
         LDA #$20        ; Initial delay
         STA $0225       ; For: A in battle
         LDA $1D54       ; Game options
         AND #$40        ; Custom buttons?
         BEQ C3AC6C      ; Reset if not
         JSR C3ADEF      ; Apply user keys		=== SNES: Dummy feature
         RTL             ; Exit
C3AC6C:  JSR C3ADFC      ; Reset buttons
         RTL

; Decode joypads for battle
C3AC70:  LDA $1D54       ; Two players?
         BPL C3AC83      ; Branch if not
         TDC             ; Clear A
         LDA $0201       ; Member slot
         TAX             ; Index it
         LDA $1D4F       ; Assigned pad
         AND.L C3AD68,X  ; Player 2's?
         BNE C3AC88      ; Branch if so
C3AC83:  LDX $4218       ; Player 1 keys
         BRA C3AC8D      ; Skip 2 lines
C3AC88:  LDX $421A       ; Player 2 keys
         BRA C3AC8D      ; ...
C3AC8D:  JSR C3ACAE      ; Decode keys
         JSR C3ACE8      ; Do autofire
         JSR C3AD21      ; Adjust it
         JMP C3AD52      ; Restore $E0+

; Decode joypads for field menu
C3AC99:  LDX $4218       ; Player 1 keys
         JSR C3ACAE      ; Decode keys
         JSR C3ACE8      ; Do autofire
         JMP C3AD52      ; Restore $E0+

; Decode joypads for field
C3ACA5:  LDX $4218       ; Player 1 keys
         JSR C3ACAE      ; Decode keys
         JMP C3AD52      ; Restore $E0+

; Update non-time-based joypad keys
C3ACAE:  LDY $E0         ; Temp var
         STY $0213       ; Make backup
         LDY $E7         ; Temp var
         STY $0215       ; Make backup
         LDY $E9         ; Temp var
         STY $0217       ; Make backup
         LDY $EB         ; Temp var
         STY $0219       ; Make backup
         STX $EB         ; Save pad keys
         REP #$20        ; 16-bit A
         LDA $0C         ; Former keys
         AND #$FFF0      ; Unused bits...
         STA $E0         ; Memorize them
         JSR C3AD6C      ; Convert keys
         LDA $0C         ; Former keys
         EOR #$FFFF      ; Invert them
         AND $06         ; Keep current
         STA $08         ; Set no-auto keys
         LDY $06         ; Pushed keys
         STY $0C         ; Set former keys
         LDA $4218       ; Player 1 keys
         ORA $421A       ; Add player 2's
         STA $04         ; Set merged keys
         SEP #$20        ; 8-bit A
         RTS

; Update slow autofire keys
C3ACE8:  REP #$20        ; 16-bit A
         LDA $06         ; Pushed keys
         AND #$FFF0      ; Clear pad type
         CMP $E0         ; Unchanged?
         SEP #$20        ; 8-bit A
         BNE C3AD10      ; Use new if not
         LDA $0227       ; Initial delay
         BEQ C3ACFF      ; Branch if over
         DEC $0227       ; Initial delay -1
         BNE C3AD1C      ; No keys if > 0
C3ACFF:  DEC $0228       ; Repeat delay -1
         BNE C3AD1C      ; No keys if > 0
         LDA $022A       ; Delay: 3
         STA $0228       ; Set repeat timer
         LDY $06         ; Pushed keys
         STY $0A         ; Set slow keys
         BRA C3AD20      ; Exit
C3AD10:  LDA $0229       ; Delay: 8
         STA $0227       ; Set initial
         LDA $022A       ; Delay: 3
         STA $0228       ; Set repeat timer
C3AD1C:  LDY $08         ; No-autofire keys
         STY $0A         ; Set slow keys
C3AD20:  RTS

; Adjust slow autofire keys for battle
C3AD21:  LDA $06         ; Pushed keys
         BIT #$80        ; Pushing A?
         BEQ C3AD42      ; Branch if not
         LDA $0225       ; Initial delay
         BEQ C3AD31      ; Branch if over
         DEC $0225       ; Initial delay -1
         BNE C3AD4D      ; New keys if > 0
C3AD31:  DEC $0226       ; Repeat delay -1
         BNE C3AD4D      ; New keys if > 0
         LDA $022A       ; Delay: 3
         STA $0226       ; Set repeat timer
         LDA #$80        ; Button: A
         TSB $0A         ; Add to slow keys
         BRA C3AD51      ; Exit
C3AD42:  LDA #$20        ; Delay: 32
         STA $0225       ; Set initial
         LDA $022A       ; Delay: 3
         STA $0226       ; Set repeat timer
C3AD4D:  LDA $08         ; No-autofire keys
         STA $0A         ; Set slow keys
C3AD51:  RTS

; Restore backup of multipurpose variables
C3AD52:  LDY $0213       ; $E0 backup
         STY $E0         ; Restore it
         LDY $0215       ; $E7 backup
         STY $E7         ; Restore it
         LDY $0217       ; $E9 backup
         STY $E9         ; Restore it
         LDY $0219       ; $EB backup
         STY $EB         ; Restore it
         TDC             ; Clear A
         RTL

; Bitfield for joypad assignments
C3AD68:  db $01          ; Member 1
         db $02          ; Member 2
         db $04          ; Member 3
         db $08          ; Member 4

; Convert pushed keys based on user settings
C3AD6C:  LDA $EB         ; Pushed keys
         AND #$0F00      ; Get D-Pad's
         STA $06         ; Set fast keys
         LDA #$0080      ; Target: A
         STA $E7         ; Set key #1
         LDA #$8000      ; Target: B
         STA $E9         ; Set key #2
         LDY $00         ; Cfg index: 0
         JSR C3ADAC      ; Do A and B
         LDA #$0040      ; Target: X
         STA $E7         ; Set key #1
         LDA #$4000      ; Target: Y
         STA $E9         ; Set key #2
         INY             ; Index +1
         JSR C3ADAC      ; Do X and Y
         LDA #$0020      ; Target: L
         STA $E7         ; Set key #1
         LDA #$0010      ; Target: R
         STA $E9         ; Set key #2
         INY             ; Index +1
         JSR C3ADAC      ; Do L and R
         LDA #$1000      ; Target: Start
         STA $E7         ; Set key #1
         LDA #$2000      ; Target: Select
         STA $E9         ; Set key #2
         INY             ; Index +1
         JMP C3ADAC      ; ...

; Convert two pushed keys to their respective purposes
C3ADAC:  LDA $EB         ; Pushed keys
         BIT $E7         ; Has key #1?
         BEQ C3ADC6      ; Skip if not
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $0220,Y     ; Key actions
         AND #$F0        ; Get key #1's
         REP #$20        ; 16-bit A
         LSR A           ; Put in b3-b6
         LSR A           ; Put in b2-b5
         LSR A           ; Put in b1-b4
         TAX             ; Index it
         LDA.L C3ADDF,X  ; Action bit
         TSB $06         ; Set fast key
C3ADC6:  LDA $EB         ; Pushed keys
         BIT $E9         ; Has key #2?
         BEQ C3ADDE      ; Exit if not
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $0220,Y     ; Key actions
         AND #$0F        ; Get key #2's
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C3ADDF,X  ; Action bit
         TSB $06         ; Set fast key
C3ADDE:  RTS

; Bitfield for button purposes
C3ADDF:  dw $1000        ; End        (Start)
         dw $0080        ; Confirm    (A)
         dw $8000        ; Cancel     (B)
         dw $0040        ; Menu       (X)
         dw $4000        ; Switch     (Y)
         dw $0020        ; Page up    (L)
         dw $0010        ; Page down  (R, Select)
         dw $2000        ; Unused

; Apply player's button settings
C3ADEF:  LDY $1D50       ; A, B, X, Y
         STY $0220       ; Set purposes
         LDY $1D52       ; L, R, Select
         STY $0222       ; Set purposes
         RTS

; Apply default button settings
C3ADFC:  LDY #$3412      ; A, B, X, Y
         STY $0220       ; Set purposes
         LDY #$0656      ; L, R, Select
         STY $0222       ; Set purposes
         RTS

; Build tilemap for SwdTech list				%%%
C3AE09:  LDX #$8049      ; Base: 7E/8049
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDX $00         ; ROM index: 0
C3AE14:  REP #$20        ; 16-bit A
         LDA.L C3AE3A,X  ; End of range
         INX             ; ROM index +1
         INX             ; ROM index +1
         STA $E7         ; Set row's limit
         LDA.L C3AE3A,X  ; Start of range
         INX             ; ROM index +1
         INX             ; ROM index +1
         TAY             ; Y = Range start
         LDA.L C3AE3A,X  ; Base attributes
         INX             ; ROM index +1
         INX             ; ROM index +1
         STA $E0         ; Memorize attribs
         SEP #$20        ; ...
         PHX             ; Save ROM index
         JSR C3B0C6      ; Build row
         PLX             ; ROM index
         CPX #$0060      ; End of table?
         BNE C3AE14      ; Loop if not
         RTS

; Tilemap data for Dispatch in SwdTech menu
C3AE3A:  dw $039C,$038A  ; Range: 6,15 to 14,15
         dw $3580        ; Tile 384, pal 5, priority
         dw $03DC,$03CA  ; Range: 6,16 to 14,16
         dw $3581        ; Tile 385, pal 5, priority

; Tilemap data for Retort in SwdTech menu
C3AE46:  dw $03B8,$03A6  ; Range: 20,15 to 28,15
         dw $3592        ; Tile 402, pal 5, priority
         dw $03F8,$03E6  ; Range: 20,16 to 28,16
         dw $3593        ; Tile 403, pal 5, priority

; Tilemap data for Slash in SwdTech menu
C3AE52:  dw $045C,$044A  ; Range: 6,18 to 14,18
         dw $35A4        ; Tile 420, pal 5, priority
         dw $049C,$048A  ; Range: 6,19 to 14,19
         dw $35A5        ; Tile 421, pal 5, priority

; Tilemap data for Quadra Slam in SwdTech menu
C3AE5E:  dw $0478,$0466  ; Range: 20,18 to 28,18
         dw $35B6        ; Tile 438, pal 5, priority
         dw $04B8,$04A6  ; Range: 20,19 to 28,19
         dw $35B7        ; Tile 439, pal 5, priority

; Tilemap data for Empowerer in SwdTech menu
C3AE6A:  dw $051C,$050A  ; Range: 6,21 to 14,21
         dw $35C8        ; Tile 456, pal 5, priority
         dw $055C,$054A  ; Range: 6,22 to 14,22
         dw $35C9        ; Tile 457, pal 5, priority

; Tilemap data for Stunner in SwdTech menu
C3AE76:  dw $0538,$0526  ; Range: 20,21 to 28,21
         dw $35DA        ; Tile 474, pal 5, priority
         dw $0578,$0566  ; Range: 20,22 to 28,22
         dw $35DB        ; Tile 475, pal 5, priority

; Tilemap data for Quadra Slice in SwdTech menu
C3AE82:  dw $05DC,$05CA  ; Range: 6,24 to 14,24
         dw $35EC        ; Tile 492, pal 5, priority
         dw $061C,$060A  ; Range: 6,25 to 14,25
         dw $35ED        ; Tile 493, pal 5, priority

; Tilemap data for Cleave in SwdTech menu
C3AE8E:  dw $05F8,$05E6  ; Range: 20,24 to 28,24
         dw $35FE        ; Tile 510, pal 5, priority
         dw $0638,$0626  ; Range: 20,25 to 28,25
         dw $35FF        ; Tile 511, pal 5, priority

; Load and upload VWF name graphics for every known SwdTech
C3AE9A:  LDX $00         ; Src: 7E/1CF8
         LDA #$01        ; Dispatch bit
         JSR C3AF24      ; Load name GFX
         LDY #$6C00      ; VRAM: $6C00
         JSR C3AF53      ; Upload GFX
         LDX #$0006      ; Src: 7E/1CFE
         LDA #$02        ; Retort bit
         JSR C3AF24      ; Load name GFX
         LDY #$6C90      ; VRAM: $6C90
         JSR C3AF53      ; Upload GFX
         LDX #$000C      ; Src: 7E/1D04
         LDA #$04        ; Slash bit
         JSR C3AF24      ; Load name GFX
         LDY #$6D20      ; VRAM: $6D20
         JSR C3AF53      ; Upload GFX
         LDX #$0012      ; Src: 7E/1D0A
         LDA #$08        ; Quadra Slam
         JSR C3AF24      ; Load name GFX
         LDY #$6DB0      ; VRAM: $6DB0
         JSR C3AF53      ; Upload GFX
         LDX #$0018      ; Src: 7E/1D10
         LDA #$10        ; Empowerer bit
         JSR C3AF24      ; Load name GFX
         LDY #$6E40      ; VRAM: $6E40
         JSR C3AF53      ; Upload GFX
         LDX #$001E      ; Src: 7E/1D16
         LDA #$20        ; Stunner bit
         JSR C3AF24      ; Load name GFX
         LDY #$6ED0      ; VRAM: $6ED0
         JSR C3AF53      ; Upload GFX
         LDX #$0024      ; Src: 7E/1D1C
         LDA #$40        ; Quadra Slice
         JSR C3AF24      ; Load name GFX
         LDY #$6F60      ; VRAM: $6F60
         JSR C3AF53      ; Upload GFX
         LDX #$002A      ; Src: 7E/1D22
         LDA #$80        ; Cleaver bit
         JSR C3AF24      ; Load name GFX
         LDY #$6FF0      ; VRAM: $6FF0
         JSR C3AF53      ; Upload GFX
         JMP C30FF4      ; Dequeue upload

; Clear buffer for storing SwdTech name or actor pseudonym in ending	=== SNES: Pseudonym only
C3AF0C:  TDC             ; Clear A
         TAX             ; Index: 0
         REP #$20        ; 16-bit A
C3AF10:  STA $7EA271,X   ; Tile row A
         INX             ; Index +1
         INX             ; Index +1
         STA $7EA271,X   ; Tile row B
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0240      ; Done 36 tiles?
         BNE C3AF10      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Load VWF name graphics for current SwdTech, unfreeze CGRAM	%%%
C3AF24:  STA $E0         ; Save SwdTech
         PHX             ; Save char index
         JSR C3AF0C      ; Clear GFX buffer
         PLX             ; Character index
         LDA $1CF7       ; Known SwdTechs
         AND $E0         ; Includes ours?
         BEQ C3AF4E      ; Exit if not
         STZ $8D         ; String width: 0
         STZ $ED         ; VRAM index LB: 0
         STZ $EE         ; VRAM index HB: 0
         LDA #$06        ; Letters: 6
         STA $F1         ; Set counter
C3AF3C:  LDA $1CF8,X     ; Name letter
         LDY #$3F40      ; Base: C4/D400
         STY $EB         ; Set font index
         PHX             ; Save char index
         JSR C3B227      ; Load graphics
         PLX             ; Char index
         INX             ; Char index +1
         DEC $F1         ; One less char
         BNE C3AF3C      ; Loop till last
C3AF4E:  LDA #$01        ; CGRAM: Refresh
         TSB $45         ; Set NMI flag
         RTS

; Upload VWF graphics for element or SwdTech menu kanji; freeze CGRAM		=== SNES: Elements only
C3AF53:  JSR C3AF5D      ; Set src and dst
         LDA #$01        ; CGRAM: Freeze
         TRB $45         ; Set NMI flag
         JMP C31517      ; Upload graphics

; Set to upload VWF string graphics (elements, SwdTech, ending pseudonym)	=== SNES: Not SwdTech
C3AF5D:  STY $1B         ; Set VRAM ptr
         LDY #$A271      ; 7E/A271
         STY $1D         ; Set src LBs
         LDY #$0120      ; Bytes: 288
         STY $19         ; Set data size
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         RTS

; Build tilemap for actor's pseudonym in ending
C3AF6E:  LDX #$7849      ; Base: 7E/7849
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$05A6      ; Ends at 19,23		=== SNES: 12,23
         STY $E7         ; Set row's limit
         LDY #$059A      ; Starts at 14,23		=== SNES: 1,23
         LDX #$2410      ; Tile 16, pal 1
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Build row 1
         LDY #$05E6      ; Ends at 19,24		=== SNES: 12,24
         STY $E7         ; Set row's limit
         LDY #$05DA      ; Starts at 14,24		=== SNES: 1,24
         LDX #$2411      ; Tile 17, pal 1
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Build row 2
         RTS

; Load and set to upload VWF graphics for actor's pseudonym
C3AF98:  JSR C3AF0C      ; Clear GFX buffer
         LDA #$08        ; Pixels: 8			%%% SNES: Varies by character
         STA $B6         ; Set char width
         STZ $8D         ; String width: 0
         STZ $ED         ; VRAM index LB: 0
         STZ $EE         ; VRAM index HB: 0
         LDA #$06        ; Letters: 6
         STA $F1         ; Set counter
         LDX $00         ; Letter index: 0
C3AFAB:  LDA $7E9E89,X   ; Letter
         LDY #$5540      ; Base: C4/EA00		=== SNES: Only one font
         STY $EB         ; Set font index
         PHX             ; Save char index
         JSR C3B227      ; Load graphics
         PLX             ; Letter index
         INX             ; Letter index +1
         DEC $F1         ; One less letter
         BNE C3AFAB      ; Loop till last
         LDY #$2080      ; VRAM pointer
         JSR C3AF5D      ; Queue upload
         RTS

; Build description tilemap for Skills submenus
C3AFC5:  LDX #$8049      ; Base: 7E/8049
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$00BC      ; Ends at 30,3
         STY $E7         ; Set row's limit
         LDY #$0094      ; Starts at 11,3		=== SNES: 3,3
         LDX #$3500      ; Tile 256, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Build row 1
         LDY #$00FC      ; Ends at 30,4
         STY $E7         ; Set row's limit
         LDY #$00D4      ; Starts at 11,4		=== SNES: 3,4
         LDX #$3501      ; Tile 257, pal 5
         STX $E0         ; Priority enabled
         JMP C3B0C6      ; Build row 2













; Build description tilemap for Relic menu
C3AFEE:  LDX #$7849      ; Base: 7E/7849
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$01BC      ; Ends at 30,7
         STY $E7         ; Set row's limit
         LDY #$0184      ; Starts at 3,7
         LDX #$3500      ; Tile 256, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 1, row 1
         LDY #$01FC      ; Ends at 30,8
         STY $E7         ; Set row's limit
         LDY #$01C4      ; Starts at 3,8
         LDX #$3501      ; Tile 257, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 1, row 2
         LDY #$023C      ; Ends at 30,9
         STY $E7         ; Set row's limit
         LDY #$0204      ; Starts at 3,9
         LDX #$3538      ; Tile 312, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 2, row 1
         LDY #$027C      ; Ends at 30,10
         STY $E7         ; Set row's limit
         LDY #$0244      ; Starts at 3,10
         LDX #$3539      ; Tile 313, pal 5
         STX $E0         ; Priority enabled
         JMP C3B0C6      ; Do line 2, row 2

; Build description tilemap for shop menu
C3B037:  LDX #$7849      ; Base: 7E/7849
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$04BC      ; Ends at 30,19
         STY $E7         ; Set row's limit
         LDY #$0484      ; Starts at 3,19
         LDX #$3500      ; Tile 256, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 1, row 1
         LDY #$04FC      ; Ends at 30,20
         STY $E7         ; Set row's limit
         LDY #$04C4      ; Starts at 3,20
         LDX #$3501      ; Tile 257, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 1, row 2
         LDY #$053C      ; Ends at 30,21
         STY $E7         ; Set row's limit
         LDY #$0504      ; Starts at 3,21
         LDX #$3538      ; Tile 312, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 2, row 1
         LDY #$057C      ; Ends at 30,22
         STY $E7         ; Set row's limit
         LDY #$0544      ; Starts at 3,22
         LDX #$3539      ; Tile 313, pal 5
         STX $E0         ; Priority enabled
         JMP C3B0C6      ; Do line 2, row 2

; Build description tilemap for Item or Colosseum menu
C3B080:  LDX #$7849      ; Base: 7E/7849
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$01BC      ; Ends at 30,7
         STY $E7         ; Set row's limit
         LDY #$0184      ; Starts at 3,7
         LDX #$3500      ; Tile 256, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 1, row 1
         LDY #$01FC      ; Ends at 30,8
         STY $E7         ; Set row's limit
         LDY #$01C4      ; Starts at 3,8
         LDX #$3501      ; Tile 257, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 1, row 2
         LDY #$023C      ; Ends at 30,9
         STY $E7         ; Set row's limit
         LDY #$0204      ; Starts at 3,9
         LDX #$3538      ; Tile 312, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Do line 2, row 1
         LDY #$027C      ; Ends at 30,10
         STY $E7         ; Set row's limit
         LDY #$0244      ; Starts at 3,10
         LDX #$3539      ; Tile 313, pal 5
         STX $E0         ; Priority enabled
C3B0C6:  REP #$20        ; 16-bit A
C3B0C8:  LDA $E0         ; Tile attributes
         STA [$EB],Y     ; Put in tilemap
         INC $E0         ; Tile +1
         INC $E0         ; Tile +1
         INY             ; Index +1
         INY             ; Index +1
         CPY $E7         ; Beyond range?
         BNE C3B0C8      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Clear buffer for VWF description graphics
C3B0D9:  PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         TAX             ; Tile index: 0
         REP #$20        ; 16-bit A
C3B0E2:  STZ $A271,X     ; Tile A, row 1
         STZ $A273,X     ; Tile A, row 2
         STZ $A275,X     ; Tile A, row 3
         STZ $A277,X     ; Tile A, row 4
         STZ $A279,X     ; Tile A, row 5
         STZ $A27B,X     ; Tile A, row 6
         STZ $A27D,X     ; Tile A, row 7
         STZ $A27F,X     ; Tile A, row 8
         STZ $A281,X     ; Tile B, row 1
         STZ $A283,X     ; Tile B, row 2
         STZ $A285,X     ; Tile B, row 3
         STZ $A287,X     ; Tile B, row 4
         STZ $A289,X     ; Tile B, row 5
         STZ $A28B,X     ; Tile B, row 6
         STZ $A28D,X     ; Tile B, row 7
         STZ $A28F,X     ; Tile B, row 8
         STZ $A291,X     ; Tile C, row 1
         STZ $A293,X     ; Tile C, row 2
         STZ $A295,X     ; Tile C, row 3
         STZ $A297,X     ; Tile C, row 4
         STZ $A299,X     ; Tile C, row 5
         STZ $A29B,X     ; Tile C, row 6
         STZ $A29D,X     ; Tile C, row 7
         STZ $A29F,X     ; Tile C, row 8
         STZ $A2A1,X     ; Tile D, row 1
         STZ $A2A3,X     ; Tile D, row 2
         STZ $A2A5,X     ; Tile D, row 3
         STZ $A2A7,X     ; Tile D, row 4
         STZ $A2A9,X     ; Tile D, row 5
         STZ $A2AB,X     ; Tile D, row 6
         STZ $A2AD,X     ; Tile D, row 7
         STZ $A2AF,X     ; Tile D, row 8
         TXA             ; Tile index
         CLC             ; Prepare ADC
         ADC #$0040      ; Skip 4 tiles
         TAX             ; Reindex it
         CPX #$0700      ; Done 112 tiles?
         BNE C3B0E2      ; Loop if not
         SEP #$20        ; 8-bit A
         PLB             ; Restore DB
         RTS

; Update VWF description
C3B151:  TAX             ; Index mode
         JMP (C3B155,X)  ; Handle mode

; Jump table for the above
C3B155:  dw C3B15B       ; Clear description
         dw C3B172       ; Sustain description
         dw C3B15E       ; Initialize variables

; Mode 0: Clear description
C3B15B:  JSR C3B0D9      ; Clear desc GFX

; Mode 2: Initialize variables
C3B15E:  STZ $8D         ; Line width: 0
         LDX $2D         ; Queue index
         LDA #$01        ; Mode: 1
         STA $3649,X     ; Next: Update
         TDC             ; Clear A
         REP #$20        ; 16-bit A
         STA $33CA,X     ; Char index: 0
         STA $344A,X     ; VRAM index: 0
         SEP #$20        ; 8-bit A

; Mode 1: Sustain description
C3B172:  LDA $26         ; Menu mode
         CMP #$17        ; Item menu top?
         BEQ C3B1D0      ; Blank if so
         LDA $46         ; Menu flags
         AND #$C0        ; No scrollbar?
         BEQ C3B184      ; Branch if so
         LDA $06         ; Pushed keys
         AND #$30        ; Using L or R?
         BNE C3B1D8      ; Reset if so
C3B184:  LDA $45         ; Menu flags
         BIT #$20        ; Ignore D-Pad?
         BNE C3B190      ; Branch if so
         LDA $07         ; Pushed keys
         AND #$0F        ; Using D-Pad?
         BNE C3B1D8      ; Reset if so
C3B190:  LDA $45         ; Menu flags
         BIT #$10        ; Clear desc?
         BNE C3B1D8      ; Reset if so
         LDY $2D         ; Queue index
         LDX $344A,Y     ; VRAM index
         STX $ED         ; Memorize it
         LDX $33CA,Y     ; Char index

; Fork: Handle line break
C3B1A0:  LDA $7E9EC9,X   ; Text character
         BEQ C3B1DF      ; Branch if <end>
         CMP #$01        ; Line break?
         BNE C3B1B8      ; Branch if not
         STZ $8D         ; Line width: 0
         REP #$20        ; 16-bit A
         LDA #$0380      ; Base tile: 57
         STA $344A,Y     ; Set VRAM index
         SEP #$20        ; 8-bit A
         BRA C3B1C0      ; Queue upload

; Fork: Handle character
C3B1B8:  JSR C3B1EC      ; Decode char			=== SNES: Only one font bank
         PHX             ; Save char index
         JSR C3B227      ; Load graphics
         PLX             ; Char index

; Fork: Queue upload, advance char index
C3B1C0:  INX             ; Char index +1
         LDY $2D         ; Queue index
         REP #$20        ; 16-bit A
         TXA             ; Char index
         STA $33CA,Y     ; Put in queue
         SEP #$20        ; 8-bit A
         JSR C3B301      ; Queue upload
         SEC             ; Set to requeue
         RTS

; Fork: Clear description, stop updating
C3B1D0:  JSR C3B0D9      ; Clear desc GFX
         JSR C3B301      ; Set to upload
         CLC             ; Set to dequeue
         RTS

; Fork: Set to reset description
C3B1D8:  LDX $2D         ; Queue index
         STZ $3649,X     ; Mode: 0
         SEC             ; Set to requeue
         RTS

; Fork: Handle terminator
C3B1DF:  LDA #$01        ; CGRAM: Refresh
         TSB $45         ; Set NMI flag
         LDX $2D         ; Queue index
         LDA #$02        ; Mode: 2
         STA $3649,X     ; Next: Init
         SEC             ; Set to requeue
         RTS

; Decode character from VWF string			%%% SNES: Only one font bank
C3B1EC:  CMP #$1C        ; Control 1C?
         BEQ C3B205      ; Branch if so
         CMP #$1D        ; Control 1D?
         BEQ C3B20C      ; Branch if so
         CMP #$1E        ; Control 1E?
         BEQ C3B213      ; Branch if so
         CMP #$1F        ; Control 1F?
         BEQ C3B21A      ; Branch if so

; Fork: Kana, etc. (large version)
C3B1FC:  SEC             ; Prepare SBC
         SBC #$20        ; Make 0-based
         STZ $EB         ; Font index LB: 0
         STZ $EC         ; Font index HB: 0
         BRA C3B226      ; RTS...

; Fork: Kanji table A
C3B205:  LDY #$1340      ; Base: C4/A800
         STY $EB         ; Set font index
         BRA C3B221      ; Get true char

; Fork: Kanji table B
C3B20C:  LDY #$2940      ; Base: C4/BE00
         STY $EB         ; Set font index
         BRA C3B221      ; Get true char

; Fork: Kanji table C
C3B213:  LDY #$3F40      ; Base: C4/D400
         STY $EB         ; Set font index
         BRA C3B221      ; Get true char

; Fork: Kanji table D and smaller kana, etc.
C3B21A:  LDY #$5540      ; Base: C4/EA00
         STY $EB         ; Set font index
         BRA C3B221      ; ...
C3B221:  INX             ; Char index +1
         LDA $7E9EC9,X   ; Get true char
C3B226:  RTS

; Load VWF character's graphics into string, add shadow effect
C3B227:  PHA             ; Save char...			=== SNES: Not useless
         STA $004202     ; Set multiplicand
         LDA #$16        ; GFX data size
         STA $004203     ; Set multiplier
         LDA #$0B        ; Rows left: 11
         STA $E5         ; Set counter
         REP #$20        ; 16-bit A
         LDA $004216     ; Char index
         CLC             ; Prepare ADC
         ADC $EB         ; Add font index		=== SNES: Useless
         TAY             ; Set ROM index
         SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $8D         ; Textline width
         AND #$F8        ; Drop WIP tile's
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         CLC             ; Prepare ADC
         ADC $ED         ; Add VRAM index
         TAX             ; Set RAM index

; Fork: Load 1bpp row graphics, shift to fit string
C3B24F:  PHX             ; Save RAM index
         REP #$20        ; 16-bit A
         TYX             ; ROM index
         LDA $C494C0,X   ; 12-px row GFX		=== SNES: $C490C0
         STZ $E7         ; Blank slice C
         STZ $E9         ; Clear byte 4
         STA $E8         ; Set slices A+B
         JSR C3B2BF      ; Shift pixels

; Fork: Insert row segment C, copy as shadow below (2bpp)
C3B260:  PLX             ; RAM index
         LDA $E7         ; Slices B and C
         SEP #$20        ; 8-bit A
         ORA $7EA2B9,X   ; Add WIP plane A
         STA $7EA2B9,X   ; Set WIP plane A
         REP #$20        ; 16-bit A
         LSR A           ; Shift 1 px right
         SEP #$20        ; 8-bit A
         ORA $7EA2BC,X   ; Add WIP plane B
         STA $7EA2BC,X   ; Set WIP plane B

; Fork: Insert row segment B, copy as shadow below (2bpp)
C3B27A:  REP #$20        ; 16-bit A
         LDA $E8         ; Slices A and B
         SEP #$20        ; 8-bit A
         ORA $7EA299,X   ; Add WIP plane A
         STA $7EA299,X   ; Set WIP plane A
         REP #$20        ; 16-bit A
         LSR A           ; Shift 1 px right
         SEP #$20        ; 8-bit A
         ORA $7EA29C,X   ; Add WIP plane B
         STA $7EA29C,X   ; Set WIP plane B

; Fork: Insert row segment A, copy as shadow below (2bpp)
C3B295:  REP #$20        ; 16-bit A
         LDA $E8         ; Slices A and B
         SEP #$20        ; 8-bit A
         XBA             ; Get slice A
         ORA $7EA279,X   ; Add WIP plane A
         STA $7EA279,X   ; Set WIP plane A
         LSR A           ; Shift 1 px right
         ORA $7EA27C,X   ; Add WIP plane B
         STA $7EA27C,X   ; Set WIP plane B

; Fork: Handle next row
C3B2AD:  INX             ; RAM index +1
         INX             ; RAM index +1
         INY             ; ROM index +1
         INY             ; ROM index +1
         DEC $E5         ; One less row
         BNE C3B24F      ; Loop till last

; Fork: Add character's width to line total
C3B2B5:  TDC             ; Clear A
         PLA             ; Text char...			=== SNES: Not useless



         LDA $8D         ; Line width
         CLC             ; Prepare ADC
         ADC $B6         ; Add char width		=== SNES: $C48FC0,X
         STA $8D         ; Save changes
         RTS

; Shift VWF character's row for string insertion
C3B2BF:  SEP #$20        ; 8-bit A
         TDC             ; Clear A
         LDA $8D         ; Line width
         AND #$07        ; WIP tile's
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         JMP (C3B2CD,X)  ; Shift row

; Jump table for the above
C3B2CD:  dw C3B2DF       ; 0: 4 px left
         dw C3B2E3       ; 1: 3 px left
         dw C3B2E7       ; 2: 2 px left
         dw C3B2EB       ; 3: 1 px left
         dw C3B2EF       ; 4: Unchanged
         dw C3B2FC       ; 5: 1 px right
         dw C3B2F8       ; 6: 2 px right
         dw C3B2F4       ; 7: 3 px right
         dw C3B2F0       ; 8: 4 px right (unused)

; Shift VWF character's row left for string insertion
C3B2DF:  ASL $E7         ; Do slice B+C
         ROL $E9         ; Do slice A
C3B2E3:  ASL $E7         ; Do slice B+C
         ROL $E9         ; Do slice A
C3B2E7:  ASL $E7         ; Do slice B+C
         ROL $E9         ; Do slice A
C3B2EB:  ASL $E7         ; Do slice B+C
         ROL $E9         ; Do slice A
C3B2EF:  RTS

; Shift VWF character's row right for string insertion
C3B2F0:  LSR $E9         ; Do slice A
         ROR $E7         ; Do slice B+C
C3B2F4:  LSR $E9         ; Do slice A
         ROR $E7         ; Do slice B+C
C3B2F8:  LSR $E9         ; Do slice A
         ROR $E7         ; Do slice B+C
C3B2FC:  LSR $E9         ; Do slice A
         ROR $E7         ; Do slice B+C
         RTS

; Set to upload VWF description, freeze CGRAM
C3B301:  LDY #$6800      ; $6800
         STY $1B         ; Set VRAM ptr
         LDY #$A271      ; 7E/A271
         STY $1D         ; Set src LBs
         LDY #$0700      ; Bytes: 1792
         STY $19         ; Set data size
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         LDA #$01        ; CGRAM: Freeze
         TRB $45         ; Set NMI flag
         RTS

; Load and upload VWF graphics for all elements		=== SNES: Icons instead of kanji
C3B319:  LDX $00         ; Elem index: 0
C3B31B:  LDA $D8E990,X   ; Elem text char		=== SNES: $D8E90E
         STA $7E9EC9,X   ; Memorize it
         INX             ; Elem index +1
         CPX #$0011      ; Terminator?			=== SNES: 9 (SFC = 2-byte encoding)
         BNE C3B31B      ; Loop if not
         LDY #$6C00      ; $6C00
         STY $F1         ; Set VRAM ptr
         TDC             ; Clear A
         TAX             ; Elem index: 0
C3B330:  LDA $7E9EC9,X   ; Elem text char
         BEQ C3B352      ; Exit if none
         JSR C3B1EC      ; Decode char			=== SNES: Only one font bank
         PHX             ; Save index
         JSR C3B355      ; Load graphics
         PLX             ; Elem index
         INX             ; Elem index +1
         LDY $F1         ; VRAM pointer
         JSR C3AF53      ; Upload graphics
         REP #$20        ; 16-bit A
         LDA $F1         ; VRAM pointer
         CLC             ; Prepare ADC
         ADC #$0020      ; Skip 4 tiles
         STA $F1         ; Save changes
         SEP #$20        ; 8-bit A
         BRA C3B330      ; Do next element
C3B352:  JMP C30FF4      ; Dequeue upload

; Load element's graphics (VWF)
C3B355:  PHA             ; Save text char
         LDY #$0040      ; Bytes: 64
         STY $F3         ; Set buffer size
         JSR C3C2CD      ; Clear GFX buffer
         STZ $8D         ; String width: 0
         STZ $ED         ; VRAM index LB: 0
         STZ $EE         ; VRAM index HB: 0
         PLA             ; Elem text char
         JMP C3B227      ; Load graphics

; 73: Initialize final battle lineup
C3B368:  JSR C335F7      ; Reset/Stop stuff
         JSR C37076      ; Reset BGs' X/Y
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         JSR C3B5C4      ; Load navig data
         JSR C3B5CD      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C3B45E      ; Clear candidates
         JSR C3B46D      ; Reset user's list
         JSR C3B483      ; Draw menu
         JSR C39C86      ; Set to shift text
         LDA #$74        ; C3/B395
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JSR C30F68      ; Queue text upload
         JMP C33609      ; BRT:1 + NMI

; 74: Sustain final battle lineup
C3B395:  JSR C3B4F9      ; Redraw candidates
         JSR C3B524      ; Redraw user's list
         JSR C3B5CA      ; Handle D-Pad
         JSR C30F68      ; Queue text upload

; Fork: Handle B
C3B3A1:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3B3D3      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDA $4A         ; R-List's empty?
         BEQ C3B416      ; Exit if so
         DEC $4A         ; R-List size -1
         TDC             ; Clear A
         LDA $4A         ; R-List size
         TAX             ; Index it
         LDA $0205,X     ; Last R-List char
         PHA             ; Save this actor
         LDA #$FF        ; Actor: None
         STA $0205,X     ; Clear R-List slot
         LDX $00         ; L-List slot: 1
         PLA             ; Removed actor
C3B3C0:  CMP $7E9D8A,X   ; In L-List slot?
         BEQ C3B3CC      ; Enable it if so
         INX             ; L-List slot +1
         CPX #$000C      ; Done all 12?
         BNE C3B3C0      ; Loop if not
C3B3CC:  LDA #$20        ; Color: User's
         STA $7EAA8D,X   ; Set L-List name's
         RTS

; Fork: Handle actor selection
C3B3D3:  LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BNE C3B409      ; Branch if so
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3B416      ; Exit if not
         JSR C30F1D      ; Sound: Click
         TDC             ; Clear A
         LDA $4B         ; On Reset?
         BEQ C3B417      ; Branch if so
         CMP #$0D        ; On "End"?
         BEQ C3B409      ; Branch if so
         TAX             ; Clicked slot
         LDA $7E9D89,X   ; Nobody there?
         BMI C3B416      ; Exit if so
         TDC             ; ...
         LDA $4B         ; Clicked slot
         DEC A           ; Now 0-12
         TAX             ; Index it
         LDA $7EAA8D,X   ; Name color
         CMP #$20        ; Player's?
         BNE C3B416      ; Exit if not
         JSR C3B422      ; Add chosen char
         LDA $4A         ; Selection count
         CMP #$0C        ; Added 12 actors?
         BEQ C3B41D      ; Go to End if so
         RTS

; Fork: Handle "End"
C3B409:  JSR C30F1D      ; Sound: Click
         JSR C3B43A      ; Auto-fill list
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS             ; ...
C3B416:  RTS

; Fork: Handle "Reset"
C3B417:  JSR C3B46D      ; Reset user's list
         INC $4E         ; Move cursor down
         RTS

; Fork: Put cursor on "End"
C3B41D:  LDA #$0D        ; Row: 14th
         STA $4E         ; Set cursor's
         RTS

; Add chosen actor to player's list for final battle
C3B422:  TDC             ; ...
         LDA $4A         ; Slot to fill
         TAY             ; Index it
         LDA $4B         ; Clicked slot
         TAX             ; Index it
         LDA #$28        ; Color: Gray
         STA $7EAA8C,X   ; Set L-Name's
         LDA $7E9D89,X   ; Chosen actor
         TYX             ; ...
         STA $0205,X     ; To user's list
         INC $4A         ; R-List size +1
         RTS

; Complete player's actor list for final battle
C3B43A:  LDA $4A         ; R-List size
         CMP #$0C        ; 12 actors?
         BEQ C3B45D      ; Exit if so
         TDC             ; Clear A
         TAX             ; L-List slot: 1
C3B442:  LDA $7EAA8D,X   ; Name color
         CMP #$20        ; Player's?
         BNE C3B457      ; Skip if not
         TDC             ; ...
         LDA $4A         ; R-List slot
         TAY             ; Index it
         LDA $7E9D8A,X   ; L-List actor
         STA $0205,Y     ; Add to list
         INC $4A         ; R-List slot +1
C3B457:  INX             ; L-List slot +1
         CPX #$000C      ; Done all 12?
         BNE C3B442      ; Loop if not
C3B45D:  RTS

; Clear candidate list for final battle (four unused slots)
C3B45E:  TDC             ; Clear A
         TAX             ; List slot: 1
C3B460:  LDA #$FF        ; Actor: None
         STA $7E9D89,X   ; Clear slot
         INX             ; List slot +1
         CPX #$0010      ; Done 16?...
         BNE C3B460      ; Loop if not
         RTS

; Reset player's actor list for final battle
C3B46D:  TDC             ; Clear A
         TAX             ; List slot: 1
C3B46F:  LDA #$FF        ; Actor: None
         STA $0205,X     ; Put in slot
         LDA #$20        ; Color: User's
         STA $7EAA8D,X   ; Set name color
         INX             ; List slot +1
         CPX #$000C      ; Done all 12?
         BNE C3B46F      ; Loop if not
         STZ $4A         ; List size: 0
         RTS

; Draw menu for final battle
C3B483:  LDA #$02        ; 32x64 at $0000
         STA $2107       ; Set BG1 map loc
         LDY #C3B4B9     ; C3/B4B9
         JSR C303C4      ; Draw window
         JSR C30EBD      ; Upload window
         JSR C371D0      ; Clear BG3 map A
         JSR C30ED9      ; Upload BG3 A+B
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #C3B5F4     ; Text ptrs loc
         LDY #$0006      ; Strings: 3
         JSR C3714E      ; Draw End, etc.
         JSR C3B589      ; Draw numbers
         JSR C3B4BD      ; List candidates
         JSR C3B4F9      ; Draw candidates
         JSR C30E93      ; Upload text
         JMP C30EA1      ; Upload BG1c...

; Window layout for final battle lineup
C3B4B9:  dw $588B,$181C  ; 30x26 at $588B

; Compile candidates for final battle
C3B4BD:  STZ $E6         ; List slot: 1
         TDC             ; Clear A
         TAX             ; 1st: Terra
C3B4C1:  PHX             ; Save actor
         LDA $1850,X     ; Party info
         AND #$40        ; Object's off?
         BEQ C3B4F1      ; Skip if so
         LDA $1850,X     ; Party info
         AND #$07        ; In a party?
         BEQ C3B4F1      ; Skip if not
         STX $E7         ; Save actor
         REP #$20        ; 16-bit A
         TXA             ; Actor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C370DB,X  ; Actor address
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         LDA $0000,Y     ; Actor in slot
         CMP #$0E        ; Guest?
         BCS C3B4F1      ; Skip if so
         TDC             ; Clear A
         LDA $E6         ; List slot
         TAX             ; Index it
         LDA $E7         ; Actor slot
         STA $7E9D8A,X   ; Add to list
         INC $E6         ; List slot +1
C3B4F1:  PLX             ; Actor slot
         INX             ; Actor slot +1
         CPX #$0010      ; Done all 16?
         BNE C3B4C1      ; Loop if not
         RTS

; Draw list of candidates for final battle
C3B4F9:  LDY #$39D5      ; Tilemap ptr			=== SNES: +40h as no diacritics
         STY $F5         ; Set position
         TDC             ; Clear A
         TAX             ; List slot: 1
C3B500:  JSR C3B54C      ; Set pos, WRAM
         PHX             ; Save list slot
         TDC             ; Clear A
         LDA $7EAA8D,X   ; Name palette
         STA $29         ; Set attributes
         LDA $7E9D8A,X   ; Actor in slot
         BMI C3B516      ; Blank if none
         JSR C3B560      ; Draw name
         BRA C3B519      ; Skip a line
C3B516:  JSR C3B57B      ; Blank slot
C3B519:  JSR C3B56E      ; VRAM row +2
         PLX             ; List slot
         INX             ; List slot +1
         CPX #$000C      ; Done all 12?
         BNE C3B500      ; Loop if not
         RTS

; Draw player's actor list for final battle
C3B524:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #$39F1      ; Tilemap ptr			=== SNES: +40h as no diacritics
         STY $F5         ; Set position
         TDC             ; Clear A
         TAX             ; List slot: 1
C3B52F:  JSR C3B54C      ; Set pos, WRAM
         PHX             ; Save list slot
         TDC             ; Clear A
         LDA $0205,X     ; Actor in slot
         BMI C3B53E      ; Blank if none
         JSR C3B560      ; Draw name
         BRA C3B541      ; Skip a line
C3B53E:  JSR C3B57B      ; Blank slot
C3B541:  JSR C3B56E      ; VRAM row +2
         PLX             ; List slot
         INX             ; List slot +1
         CPX #$000C      ; Done all 12?
         BNE C3B52F      ; Loop if not
         RTS

; Prepare actor name drawing for final battle lineup
C3B54C:  LDY #$9E89      ; 7E/9E89
         STY $2181       ; Set WRAM LBs
         REP #$20        ; 16-bit A
         LDA $F5         ; Tilemap ptr
         SEP #$20        ; 8-bit A
         STA $2180       ; Set position LB
         XBA             ; Switch to HB
         STA $2180       ; Set position HB
         RTS

; Draw actor's name for final battle lineup
C3B560:  ASL A           ; Actor x2
         REP #$20        ; 16-bit A
         TAX             ; Index it
         LDA.L C370DB,X  ; Actor address
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         JMP C3356D      ; Draw name

; Point two rows down in tilemap
C3B56E:  REP #$20        ; 16-bit A
         LDA $F5         ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$0080      ; +2 rows down
         STA $F5         ; Save changes
         SEP #$20        ; 8-bit A
         RTS

; Blank actor name slot
C3B57B:  LDX #$0006      ; Spaces: 6
         LDA #$FF        ; Space char
C3B580:  STA $2180       ; Add to string
         DEX             ; One less left
         BNE C3B580      ; Loop till last
         JMP C387B9      ; Draw 6 spaces

; Draw both lists of numbers for final battle lineup
C3B589:  LDA #$01        ; Number: "1"
         STA $E6         ; Set as current
         LDY #$3A0F      ; Tilemap ptr
         STY $F5         ; Set position
         LDX #$000C      ; Numbers: 12
         STX $F1         ; Set counter
         JSR C3B5AB      ; Draw left list
         LDA #$01        ; Number: "1"
         STA $E6         ; Set as current
         LDY #$3A2B      ; Tilemap ptr
         STY $F5         ; Set position
         LDX #$000C      ; Numbers: 12
         STX $F1         ; Set counter
         JMP C3B5AB      ; Draw right list

; Draw current list of numbers for final battle lineup
C3B5AB:  TDC             ; Clear A
         TAX             ; Numbers done: 0
C3B5AD:  PHX             ; Save counter
         LDA $E6         ; Current number
         JSR C30563      ; Turn into text
         LDX $F5         ; Text position
         JSR C30539      ; Draw 2 digits
         INC $E6         ; Number +1
         JSR C3B56E      ; VRAM row +2
         PLX             ; Numbers done
         INX             ; Numbers done +1
         CPX $F1         ; Done all 12?
         BNE C3B5AD      ; Loop if not
         RTS

; Load navigation data for final battle lineup
C3B5C4:  LDY #C3B5D3     ; C3/B5D3
         JMP C30681      ; Load navig data

; Handle D-Pad for final battle lineup
C3B5CA:  JSR C307B0      ; Handle D-Pad
C3B5CD:  LDY #C3B5D8     ; C3/B5D8
         JMP C306C3      ; Relocate cursor

; Navigation data for final battle lineup
C3B5D3:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $0E          ; 14 rows

; Cursor positions for final battle lineup
C3B5D8:  dw $2010        ; Reset
         dw $2C20        ; Actor 1
         dw $3820        ; Actor 2
         dw $4420        ; Actor 3
         dw $5020        ; Actor 4
         dw $5C20        ; Actor 5
         dw $6820        ; Actor 6
         dw $7420        ; Actor 7
         dw $8020        ; Actor 8
         dw $8C20        ; Actor 9
         dw $9820        ; Actor 10
         dw $A420        ; Actor 11
         dw $B020        ; Actor 12
         dw $BC10        ; End

; Text pointers for final battle lineup
C3B5F4:  dw C3B5FA       ; End
         dw C3B600       ; Reset
         dw C3B608       ; Determine order

; Positioned text for final battle lineup
C3B5FA:  dw $3FD1 : db |おわり[end]|		; End			=== SNES: +40h as no diacritics (same below)
C3B600:  dw $3951 : db |やりなおし[end]|		; Reset
C3B608:  dw $38DD : db |じゅんばんを きめてください[end]|	; Determine order

; 71: Initialize Colosseum item menu
C3B619:  STZ $0201       ; Face Shadow: No
         LDA $0205       ; Empty item...
         JSR C3A56C      ; Add to stock...
         JSR C31B48      ; Init list vars
         JSR C384AC      ; Relocate cursor
         JSR C3B696      ; Draw/Upload menu
         TDC             ; Gradient set: 0
         JSL $D4CA1D     ; Create gradient
         JSR C31B74      ; Shift & OBJ & Fade
         JSR C340B9      ; Apply user font
         LDA #$01        ; CGRAM: Refresh
         TSB $45         ; Set NMI flag
         JSR C313D3      ; Refresh screen
         LDA #$72        ; C3/B64B
         STA $27         ; Queue: Sustain menu
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         JSR C30833      ; Queue cursor OAM
         JMP C33609      ; BRT:1 + NMI

; 72: Sustain Colosseum item menu
C3B64B:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         STZ $2A         ; List type: Stock
         JSR C30F68      ; Queue list upload
         JSR C31FCA      ; Handle L and R
         BCS C3B695      ; Exit if pushed
         JSR C384A9      ; Handle D-Pad
         JSR C38A72      ; Load description

; Fork: Handle A
C3B65F:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3B683      ; Branch if not
         TDC             ; Clear A
         LDA $4B         ; Selected slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3B67D      ; Fail if so
         STA $0205       ; Set item bet
         JSR C30F1D      ; Sound: Click
         LDA #$75        ; C3/B724
         STA $27         ; Queue: Matchup
         STZ $26         ; Next: Fade-out
         RTS

; Fork: Invalid selection
C3B67D:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen

; Fork: Handle B
C3B683:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3B695      ; Exit if not
         JSR C30F14      ; Sound: Cursor
         LDA #$FF        ; Empty item
         STA $0205       ; Clear item bet
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
C3B695:  RTS

; Draw and upload Colosseum item menu
C3B696:  LDA #$01        ; 64x32 at $0000
         STA $2107       ; Set BG1 map loc
         LDY #C3B6FD     ; C3/B6FD
         JSR C303C4      ; Draw message box
         LDY #C3B6F9     ; C3/B6F9
         JSR C303C4      ; Draw title box
         LDY #C3B701     ; C3/B701
         JSR C303C4      ; Draw desc box
         LDY #C3B705     ; C3/B705
         JSR C303C4      ; Draw item box
         JSR C30EBD      ; Upload windows
         JSR C371D5      ; Clear BG3 map B
         JSR C371DA      ; Clear BG3 map C
         JSR C371DF      ; Clear BG3 map D
         JSR C3B6DD      ; Draw title, etc.
         JSR C3B6EF      ; Draw desc/"Select"
         JSR C3B319      ; Upload elements...
         JSR C30ED9      ; Upload BG3 A+B
         JSR C30EE7      ; Upload BG3 C+D
         JSR C371AD      ; Clear BG1 map B
         JSR C385BC      ; Draw inventory
         JSR C38A72      ; Load description
         JSR C30E93      ; Upload BG1 A+B
         JMP C30EA1      ; Upload BG1 C...

; Draw Colosseum menu title, clear tilemap beforehand
C3B6DD:  JSR C371D0      ; Clear BG3 map A
         LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         LDY #C3B709     ; Text pointer
         JSR C30326      ; Draw "Colosseum"
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         RTS             ; ^ For "Select..."

; Build BG3 tilemap for Colosseum item menu, excluding title
C3B6EF:  JSR C3B080      ; Build desc map
         LDY #C3B711     ; Text pointer
         JSR C30326      ; Draw "Select..."
         RTS

; Window layout for Colosseum item menu
C3B6F9:  dw $588B,$0205  ; 07x04 at $588B (Title)			=== SNES: Longer on right side
C3B6FD:  dw $5899,$0215  ; 23x04 at $5899 ("Select...")			=== SNES: Shorter on left side
C3B701:  dw $598B,$031C  ; 30x05 at $598B (Description)
C3B705:  dw $5ACB,$0F1C  ; 30x17 at $5ACB (Items)

; Positioned text for Colosseum
C3B709:  dw $78CD : db |コロシアム[end]|		; Colosseum		=== SNES: +40h as no diacritics (also below)
C3B711:  dw $78DB : db |アイテムを１つ えらんでください[end]|	; Select an Item	=== SNES: Shifted rightward

; 75: Initialize Colosseum matchup menu
C3B724:  JSR C335F7      ; Reset/Stop stuff
         STZ $43         ; Disable HDMA
         JSR C33B5B      ; Load skin visuals
         JSR C37087      ; Get party info
         LDA #$02        ; Gradient set: 2
         JSL $D4CA1D     ; Create gradient
         JSR C37170      ; Queue Win1 HDMA
         JSR C371FA      ; Load GFX/pal/prize
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         JSR C3BC90      ; Load navig data
         JSR C3BC99      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C3B774      ; Queue "VS" OAM
         JSR C3193A      ; Set to shift text
         JSR C3B7A1      ; Draw menu; members
         LDA #$01        ; CGRAM: Refresh
         TSB $45         ; Set NMI flag
         JSR C340B9      ; Apply user font
         LDA #$01        ; Min slot: 8
         LDY #C3BC12     ; C3/BC12
         JSR C311DE      ; Queue challenger fn
         LDA #$76        ; C3/B77C
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JSR C37076      ; Reset BGs' X/Y
         JSR C30F68      ; Queue enemy upload
         JSR C33609      ; BRT:1 + NMI
         JMP C30FA4      ; Queue text upload

; Queue OAM function for "VS" symbol
C3B774:  LDA #$01        ; Min slot: 8
         LDY #C3BC60     ; C3/BC60
         JMP C311DE      ; Queue OAM fn

; 76: Sustain Colosseum matchup menu
C3B77C:  JSR C30FA4      ; Queue text upload
         JSR C3BC96      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3B7A0      ; Exit if not
         JSR C3BC59      ; Actor in slot
         BMI C3B79A      ; Fail if nobody
         STA $0208       ; Set challenger
         JSR C30F1D      ; Sound: Click
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
         RTS             ; Exit
C3B79A:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
C3B7A0:  RTS

; Draw Colosseum matchup menu and create members
C3B7A1:  LDA #$01        ; 64x32 at $0000
         STA $2107       ; Set BG1 map loc
         LDY #C3BCAC     ; C3/BCAC
         JSR C303C4      ; Draw prize window
         LDY #C3BCB0     ; C3/BCB0
         JSR C303C4      ; Draw bet window
         LDY #C3BCB4     ; C3/BCB4
         JSR C303C4      ; Draw party window
         JSR C30EBD      ; Upload windows
         JSR C371D0      ; Clear BG3 map A
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         JSR C3BAEA      ; Create member 1
         JSR C3BB04      ; Create member 2
         JSR C3BB1E      ; Create member 3
         JSR C3BB38      ; Create member 4
         LDY #C3BD7C     ; Text pointer
         JSR C30326      ; Draw "Select..."
         JSR C3BBFA      ; Draw enemy name
         JSR C3BBBA      ; Draw item bet
         JSR C3BBC2      ; Draw prize
         JSR C30ED9      ; Upload BG3 A+B
         LDY #$5000      ; $5000
         STY $2116       ; Set VRAM ptr
         JSR C3BA77      ; Blank BG1 tile 1
         JSR C371A9      ; Clear BG1 map A
         JSR C3B800      ; Handle Striker
         LDA $0201       ; Facing Shadow?
         BNE C3B7FA      ; Branch if so
         JSR C3B86D      ; Draw monster
         JMP C30E93      ; Upload BG1 A+B

; Fork: Fighting Shadow
C3B7FA:  JSR C3B814      ; Do name/sprite
         JMP C30E93      ; Upload BG1 A+B

; Check if betting Striker
C3B800:  LDA $0205       ; Item bet
         CMP #$29        ; Striker?
         BNE C3B813      ; Exit if not
         LDA $1EBD       ; Event flags
         AND #$80        ; Shadow at arena?
         BEQ C3B813      ; Exit if not
         LDA #$01        ; Facing Shadow: Y
         STA $0201       ; Set arena's mode
C3B813:  RTS

; Create Shadow's name and sprite for Colosseum
C3B814:  JSR C3B846      ; Draw "Shadow"
         LDA #$02        ; For C3/8316...
         TSB $47         ; See C3/BC28...
         LDA #$02        ; Min slot: 16
         LDY #C381F3     ; C3/81F3
         JSR C311DE      ; Queue OAM fn
         LDA #$01        ; OAM mode: 1
         STA $7E3649,X   ; Set sprite's
         LDA $7E364A,X   ; Sprite flags
         ORA #$02        ; Add H-Flip
         STA $7E364A,X   ; Save changes
         TXY             ; Queue index
         LDA #$38        ; Sprite X: 56
         STA $E1         ; Memorize it
         LDA #$68        ; Sprite Y: 104
         STA $E2         ; Memorize it
         TDC             ; Clear A
         LDA #$03        ; Sprite set: 3
         JSR C3808E      ; Set anim ptr
         JSR C3BB7E      ; Set position
         RTS

; Draw Shadow's name at Colosseum
C3B846:  TDC             ; Clear A
         TAX             ; 1st: Terra
C3B848:  STX $E7         ; Save index
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor address
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA $0000,X     ; Actor in slot
         CMP #$03        ; Shadow?
         BEQ C3B865      ; Retain if so
         LDX $E7         ; Actor index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 actors?
         BNE C3B848      ; Loop if not
C3B863:  BRA C3B863      ; Freeze game...
C3B865:  STX $67         ; Save actor index
         LDY #$7C11      ; Text position		=== SNES: Fails to do +40h as no diacritics
         JMP C3356A      ; Draw actor name

; Build tilemap for Colosseum enemy
C3B86D:  LDX $91         ; Tilemap ptr
         STX $ED         ; Set dst LBs
         LDA $99         ; Monster size
         CMP #$08        ; 8x8 tiles?
         BEQ C3B883      ; Branch if so
         LDX #$0010      ; Tiles: 16
         STX $F1         ; Set height
         LDX #$0010      ; ...
         STX $E0         ; Set width
         BRA C3B88A      ; Skip 3 lines
C3B883:  LDX #$0008      ; Tiles: 8
         STX $F1         ; Set height
         STX $E0         ; Set width
C3B88A:  LDA #$7E        ; Bank: 7E
         STA $EF         ; Set dst HB
         REP #$20        ; 16-bit A
         LDA #$2C01      ; Tile 1, pal 3
         STA $E7         ; Priority: Yes
C3B895:  LDX $E0         ; Width in tiles
         LDY $00         ; Map index: 0
C3B899:  LDA $E7         ; Tile attribs
         STA [$ED],Y     ; Put in tilemap
         INY             ; Map index +1
         INY             ; Map index +1
         INC $E7         ; Tile number +1
         DEX             ; One less column
         BNE C3B899      ; Loop till last
         LDA $ED         ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         STA $ED         ; Save changes
         DEC $F1         ; One less row
         BNE C3B895      ; Loop till last
         SEP #$20        ; 8-bit A
         RTS

; Load prize and enemy data for Colosseum matchup
C3B8B3:  JSR C3BB99      ; Set enemy, prize
         LDA $0206       ; Enemy number
         STA $4202       ; Set multiplicand
         LDA #$05        ; Enemy data size
         STA $4203       ; Set multiplier
         LDY #$5010      ; $5010
         STY $2116       ; Set VRAM ptr
         NOP
         NOP
         LDX $4216       ; Index product
         LDA $D27000,X   ; GFX ptr/8 LSBs
         STA $E7         ; Save in RAM
         LDA $D27001,X   ; Ptr MSBs; flag
         STA $E8         ; Save in RAM
         LDA $D27002,X   ; Pal/Mold info
         STA $F2         ; Save in RAM
         LDA $D27003,X   ; Palette LSBs
         STA $F1         ; Save in RAM
         LDA $D27004,X   ; Mold index LSBs
         STA $E9         ; Save in RAM

; Fork: Relocate color depth flag
C3B8EA:  LDA $E8         ; 8-color palette?
         BMI C3B8F2      ; Branch if so
         STZ $FF         ; Colors: 16
         BRA C3B8FA      ; Skip other case
C3B8F2:  LDA #$01        ; Colors: 8
         STA $FF         ; Set color depth
         LDA #$80        ; 8-color flag
         TRB $E8         ; Clear original

; Fork: Compute enemy graphics address ($E97000+8X)
C3B8FA:  LDA #$E9        ; Bank: E9
         STA $F7         ; Set base adr HB
         REP #$20        ; 16-bit A
         LDA #$7000      ; E9/7000
         STA $F5         ; Set base adr LBs
         LDA $E7         ; GFX ptr / 8
         STA $F9         ; Init real ptr
         STZ $FB         ; Clear HBs
         ASL $F9         ; Ptr LBs x2
         ROL $FB         ; Ptr HBs x2 + C
         ASL $F9         ; Ptr LBs x2
         ROL $FB         ; Ptr HBs x2 + C
         ASL $F9         ; Ptr LBs x2
         ROL $FB         ; Ptr HBs x2 + C
         CLC             ; Prepare ADC
         LDA $F9         ; GFX pointer LBs
         ADC $F5         ; Add base address
         STA $F5         ; Set address LBs
         LDA $FB         ; GFX pointer HB
         ADC $F7         ; Add base address
         STA $F7         ; Set address HB
         LDX $00         ; GFX index: 0

; Fork: Set address pointer and size for 8x8 mold data
C3B926:  SEP #$20        ; 8-bit A
         LDA $F2         ; 16x16 image?
         BMI C3B935      ; Branch if so
         LDY #$A820      ; D2/A820
         STY $E3         ; Set address ptr
         LDA #$08        ; 8-tile rows: 8
         BRA C3B93C      ; Set data size

; Fork: Set address pointer and size for 16x16 mold data
C3B935:  LDY #$A822      ; D2/A822
         STY $E3         ; Set address ptr
         LDA #$20        ; 8-tile rows: 32
C3B93C:  STA $E6         ; Set rows left
         STA $99         ; Set enemy size
         LDA #$D2        ; Bank: D2
         STA $E5         ; Set pointer HB

; Fork: Define mold index's high byte
C3B944:  LDA $F2         ; Monster flags
         AND #$40        ; Mold index MSB
         ROL A           ; Put in bit 7
         ROL A           ; Put in Carry
         ROL A           ; Put in bit 0
         STA $EA         ; Set index HB

; Fork: Load address to 8x8 enemy's mold ($D2A824+8X)
C3B94D:  LDA $F2         ; 16x16 image?
         BMI C3B95A      ; Branch if so
         REP #$20        ; 16-bit A
         LDA $E9         ; Mold index
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         BRA C3B963      ; Set address

; Fork: Load address to 16x16 enemy's mold ($D2AC24+32X)
C3B95A:  REP #$20        ; 16-bit A
         LDA $E9         ; Mold index
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
C3B963:  CLC             ; Prepare ADC
         ADC [$E3]       ; Add base adr
         STA $E0         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA #$D2        ; Bank: D2
         STA $E2         ; Set src HB

; Fork: Load 8-tile row, blank tiles excluded from mold
C3B96E:  LDY #$0008      ; Columns: 8
         PHX             ; Save GFX index
         TDC             ; Clear A
         LDA $E6         ; Rows left
         TAX             ; Index it
         LDA [$E0]       ; Mold row flags
         STA $7E9D88,X   ; For centering
         PLX             ; GFX index
C3B97D:  CLC             ; Prepare ROL
         PHY             ; Save column
         ROL A           ; Blank tile here?
         PHA             ; Save mold flags
         BCC C3B988      ; Branch if blank
         JSR C3BA8B      ; Load tile's GFX
         BRA C3B98B      ; Skip a line
C3B988:  JSR C3BA77      ; Make blank tile
C3B98B:  PLA             ; Mold row flags
         PLY             ; Columns left
         DEY             ; One less left
         BNE C3B97D      ; Loop till last

; Fork: Handle next 8-tile row
C3B990:  REP #$20        ; 16-bit A
         INC $E0         ; Mold data adr +1
         SEP #$20        ; 8-bit A
         DEC $E6         ; One less row
         BNE C3B96E      ; Loop till last

; Fork: Set position and load colors
C3B99A:  JSR C3B9A0      ; Set tilemap ptr
         JMP C3BAC7      ; Load enemy pal

; Position Colosseum enemy based on size
C3B9A0:  STZ $E0         ; Blank rows: 0
         STZ $E4         ; Rel pos LB: 0
         STZ $E5         ; Rel pos HB: 0
         STZ $E3         ; Clear filled cols
         LDX $00         ; 1st: Bottom row
         LDA $99         ; Monster size
         CMP #$08        ; 8x8 tiles?
         BNE C3B9E6      ; Branch if not

; Fork: Count blank rows, identify filled columns (8x8)
C3B9B0:  LDA $7E9D89,X   ; Blank row here?
         BNE C3B9BD      ; Branch if not
         INC $E0         ; Blank rows +1
         INX             ; Point 1 row up
         CMP #$08        ; Bogus...
         BNE C3B9B0      ; Test next row
C3B9BD:  LDX $00         ; 1st: Bottom row
C3B9BF:  LDA $7E9D89,X   ; Row's filled cols
         ORA $E3         ; Add prior rows'
         STA $E3         ; Save merged rows
         INX             ; Point 1 row up
         CPX #$0008      ; Done all 8 rows?
         BNE C3B9BF      ; Loop if not

; Fork: Position 8x8 enemy based on empty columns
C3B9CD:  ROR $E3         ; Empty column here?
         BCS C3B9D5      ; Branch if not
         INC $E4         ; Relative pos +1
         BRA C3B9CD      ; Test next column
C3B9D5:  LSR $E4         ; If odd-numbered:
         ASL $E4         ; Relative pos -1
         REP #$21        ; 16-bit A; C-
         LDA $E4         ; Relative position
         ADC #$3A51      ; X+4, Y+8 tiles
         STA $E7         ; Save tilemap ptr
         SEP #$20        ; 8-bit A
         BRA C3BA21      ; Adjust Y position

; Fork: Count blank rows, identify R-Half's filled columns (16x16)
C3B9E6:  LDA $7E9D89,X   ; Row's right half
         ORA $7E9D8A,X   ; L-Half empty too?
         BNE C3B9F9      ; Branch if not
         INC $E0         ; Blank rows +1
         INX             ; 8-tile index +1
         INX             ; 8-tile index +1
         CPX #$0020      ; Done all 16 rows?
         BNE C3B9E6      ; Loop if not
C3B9F9:  LDX $00         ; 1st: Bottom row
C3B9FB:  LDA $7E9D89,X   ; R-Half filled cols
         ORA $E3         ; Add prior rows'
         STA $E3         ; Save merged rows
         INX             ; 8-tile index +1
         INX             ; 8-tile index +1
         CPX #$0020      ; Done all 16 rows?
         BNE C3B9FB      ; Loop if not

; Fork: Position 16x16 enemy based on empty columns
C3BA0A:  ROR $E3         ; Empty column?
         BCS C3BA12      ; Branch if not
         INC $E4         ; Relative pos +1
         BRA C3BA0A      ; Test next column
C3BA12:  LSR $E4         ; If odd-numbered:
         ASL $E4         ; Relative pos -1
         REP #$21        ; 16-bit A; C-
         LDA $E4         ; Relative position
         ADC #$3849      ; Add base address
         STA $E7         ; Save tilemap ptr
         SEP #$20        ; 8-bit A
C3BA21:  JMP C3BA24      ; ...

; Fork: Adjust Y position based on enemy and blank rows
C3BA24:  TDC             ; Clear A
         LDA $0206       ; Enemy number
         TAX             ; Index it
         LDA $ECE800,X   ; Modifier index
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         JMP (C3BA36,X)  ; Shift enemy

; Jump table for the above
C3BA36:  dw C3BA40       ; Shift up by 3
         dw C3BA65       ; Shift down by $E0
         dw C3BA4F       ; Shift down by $E0 - 1
         dw C3BA57       ; Shift down by $E0 + 1
         dw C3BA5B       ; Shift down by $E0 - 3

; Shift enemy up by 3 tiles
C3BA40:  STZ $E0         ; Blank rows: 0
         REP #$20        ; 16-bit A
         LDA $E7         ; Tilemap ptr
         SEC             ; Prepare SBC
         SBC #$00C0      ; Go 3 rows up
         STA $91         ; Save map ptr
         SEP #$20        ; 8-bit A
         RTS

; Shift enemy down by $E0 - 1
C3BA4F:  DEC $E0         ; Blank rows -1
         BPL C3BA55      ; Branch if 0+
         STZ $E0         ; Blank rows: 0
C3BA55:  BRA C3BA65      ; Shift enemy

; Shift enemy down by $E0 + 1
C3BA57:  INC $E0         ; Blank rows +1
         BRA C3BA65      ; Shift enemy

; Shift enemy down by $E0 - 3
C3BA5B:  DEC $E0         ; Blank rows -1
         DEC $E0         ; Blank rows -1
         DEC $E0         ; Blank rows -1
         BPL C3BA65      ; Branch if 0+
         STZ $E0         ; Blank rows: 0

; Shift enemy down by $E0
C3BA65:  TDC             ; ...
         LDA $E0         ; Blank rows
         REP #$21        ; 16-bit A; C-
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         ASL A           ; x32
         ASL A           ; x64
         ADC $E7         ; Add map ptr
         STA $91         ; Save map ptr
         SEP #$20        ; 8-bit A
         RTS

; Create a blank tile at current location in VRAM
C3BA77:  LDY #$0010      ; Rows: 8
         STY $E3         ; Set loop limit
         REP #$20        ; 16-bit A
         LDY $00         ; Loop count: 0
C3BA80:  STZ $2118       ; 8 px, 2 planes
         INY             ; Loop count +1
         CPY $E3         ; Done 8 rows?
         BNE C3BA80      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Upload current tile from monster's tileset
C3BA8B:  LDA $FF         ; Has 8 colors?
         BNE C3BA96      ; Branch if so
         LDY #$0010      ; Bytes: 32
         STY $E3         ; Set loop limit
         BRA C3BAB2      ; Load tile GFX

; Fork: Load 8-color tile, encode as 4bpp
C3BA96:  LDY #$0008      ; Bytes: 16
         STY $E3         ; Set loop limit
         JSR C3BAB2      ; Load rows' LSBs
         TXY             ; ...
         LDX #$0008      ; Rows left: 8
         TDC             ; Clear A
C3BAA3:  LDA [$F5],Y     ; GFX row's MSBs
         REP #$20        ; 16-bit A
         STA $2118       ; Save in VRAM
         SEP #$20        ; 8-bit A
         INY             ; GFX index +1
         DEX             ; One less row
         BNE C3BAA3      ; Loop till last
         TYX             ; GFX index
         RTS

; Fork: Upload specified number of words
C3BAB2:  TXY             ; GFX index
         LDX $00         ; Loop count: 0
         REP #$20        ; 16-bit A
C3BAB7:  LDA [$F5],Y     ; 8 px, 2 planes
         STA $2118       ; Save in VRAM
         INY             ; GFX index +1
         INY             ; GFX index +1
         INX             ; Loop count +1
         CPX $E3         ; Beyond range?
         BNE C3BAB7      ; Loop if not
         SEP #$20        ; 8-bit A
         TYX             ; GFX index
         RTS

; Load monster's palette
C3BAC7:  REP #$20        ; 16-bit A
         LDA $F1         ; Palette index
         AND #$03FF      ; Clear flags
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDY #$30A9      ; 7E/30A9
         STY $2181       ; Set WRAM LBs
         LDY #$0020      ; Colors: 16
C3BADE:  LDA $D27820,X   ; Color data
         STA $2180       ; To BG pal 3
         INX             ; ROM index +1
         DEY             ; One less byte
         BNE C3BADE      ; Loop till last
         RTS

; Create Colosseum member 1
C3BAEA:  LDY $6D         ; Actor's address
         BEQ C3BB03      ; Exit if nobody
         STY $67         ; Memorize it
         LDY #$7E4F      ; Text position		=== SNES: Fails to do +40h as no diacritics
         JSR C3BB52      ; Draw name; OAM
         LDA #$20        ; Sprite's X: 32
         STA $E1         ; Memorize it
         LDA #$A8        ; Sprite's Y: 168
         STA $E2         ; Memorize it
         LDA $69         ; Actor's slot
         JSR C3BB60      ; Init sprite
C3BB03:  RTS

; Create Colosseum member 2
C3BB04:  LDY $6F         ; Actor's address
         BEQ C3BB1D      ; Exit if nobody
         STY $67         ; Memorize it
         LDY #$7E5D      ; Text position		=== SNES: Fails to do +40h as no diacritics
         JSR C3BB52      ; Draw name; OAM
         LDA #$58        ; Sprite's X: 88
         STA $E1         ; Memorize it
         LDA #$A8        ; Sprite's Y: 168
         STA $E2         ; Memorize it
         LDA $6A         ; Actor
         JSR C3BB60      ; Init sprite
C3BB1D:  RTS

; Create Colosseum member 3
C3BB1E:  LDY $71         ; Actor's address
         BEQ C3BB37      ; Exit if nobody
         STY $67         ; Memorize it
         LDY #$7E6B      ; Text position		=== SNES: Fails to do +40h as no diacritics
         JSR C3BB52      ; Draw name; OAM
         LDA #$90        ; Sprite's X: 144
         STA $E1         ; Memorize it
         LDA #$A8        ; Sprite's Y: 168
         STA $E2         ; Memorize it
         LDA $6B         ; Actor's slot
         JSR C3BB60      ; Init sprite
C3BB37:  RTS

; Create Colosseum member 4
C3BB38:  LDY $73         ; Actor's address
         BEQ C3BB51      ; Exit if nobody
         STY $67         ; Memorize it
         LDY #$7E79      ; Text position
         JSR C3BB52      ; Draw name; OAM		=== SNES: Fails to do +40h as no diacritics
         LDA #$C8        ; Sprite's X: 200
         STA $E1         ; Memorize it
         LDA #$A8        ; Sprite's Y: 168
         STA $E2         ; Memorize it
         LDA $6C         ; Actor's slot
         JSR C3BB60      ; Init sprite
C3BB51:  RTS

; Draw Colosseum member's name, queue sprite function
C3BB52:  JSR C3356A      ; Draw actor name
         LDA #$02        ; Min slot: 16
         LDY #C381F3     ; C3/81F3
         JSR C311DE      ; Queue OAM fn
         TXY             ; Queue index
         TDC             ; Clear A
         RTS

; Initialize Colosseum actor sprite, excluding enemy Shadow
C3BB60:  ASL A           ; Actor x2
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C370DB,X  ; Actor address
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA $0014,X     ; Status
         AND #$20        ; Imp?
         BEQ C3BB77      ; Branch if not
         TDC             ; Clear A
         LDA #$0F        ; Use Imp set
         BRA C3BB7B      ; Skip 2 lines
C3BB77:  TDC             ; Clear A
         LDA $0001,X     ; Sprite set
C3BB7B:  JSR C3808E      ; Set anim ptr
C3BB7E:  LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set ptr HB
         LDA $E1         ; X position
         STA $33CA,Y     ; Set sprite's
         LDA $E2         ; Y position
         STA $344A,Y     ; Set sprite's
         TDC             ; Clear A
         STA $33CB,Y     ; No use...
         STA $344B,Y     ; No use...
         LDA #$00        ; Clear A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         RTS

; Load opponent and prize data for item bet
C3BB99:  TDC             ; Clear A
         LDA $0205       ; Item bet
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA $D0F200,X   ; Opponent			=== SNES: $DFB600
         STA $0206       ; Save in RAM
         LDA $D0F202,X   ; Prize			=== SNES: $DFB602
         STA $0207       ; Save in RAM
         LDA $D0F203,X   ; Hide Prize flag		=== SNES: $DFB603
         STA $0209       ; Save in RAM
         RTS             ; ^ Read below

; Draw Colosseum bet
C3BBBA:  LDA $0205       ; Item bet
         LDX #$78EF      ; Text position		=== SNES: +40h as no diacritics; shifted leftward (longer names)
         BRA C3BBD0      ; Draw item name

; Draw Colosseum prize
C3BBC2:  LDA $0209       ; Hide prize?
         BEQ C3BBCA      ; Branch if not
         JMP C3BBF3      ; Draw "???..."
C3BBCA:  LDA $0207       ; Prize
         LDX #$78D1      ; Tilemap ptr			=== SNES: +40h as no diacritics; shifted leftward (longer names)
C3BBD0:  PHA             ; Save item
         LDY #$9E8B      ; 7E/9E8B
         STY $2181       ; Set WRAM LBs
         REP #$20        ; 16-bit A
         TXA             ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
C3BBE0:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C3BBE0      ; Loop if not
         PLA             ; Item
         JSR C3884F      ; Load "<item>:"
         TDC             ; Terminator
         STA $7E9E94     ; Remove ":"			=== SNES: $7E9E98 (longer item names)
         JMP C387B9      ; Draw item name

; Fork: Draw question marks
C3BBF3:  LDY #C3BD8E     ; Text pointer
         JSR C302F9      ; Draw string
         RTS

; Draw monster's name for Colosseum
C3BBFA:  REP #$20        ; 16-bit A
         LDA #$7C11      ; Tilemap ptr			=== SNES: +40h as no diacritics; shifted leftward as longer names
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         JSR C35A64      ; Define source
         TDC             ; ...
         LDA $0206       ; Opponent
         JSR C38BF2      ; Load name
         JMP C387B9      ; Draw name

; Update Colosseum challenger's name and sprite
C3BC12:  PHB             ; Save DB
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDY $6D,X       ; Actor address
         BEQ C3BC4C      ; Blank if nobody
         STY $67         ; Memorize it
         LDY #$7C35      ; Text position		=== SNES: +40h as no diacritics
         JSR C3356A      ; Draw actor name
         LDA #$02        ; Temp sprite: Y
         TSB $47         ; Set menu flag
         LDA #$02        ; Min slot: 16
         LDY #C382C9     ; C3/82C9
         JSR C311DE      ; Queue OAM fn
         LDA #$01        ; Anim mode: 1
         STA $7E3649,X   ; Set sprite's
         TXY             ; Queue index
         TDC             ; Clear A
         LDA #$B8        ; Sprite's X: 184
         STA $E1         ; Memorize it
         LDA #$68        ; Sprite's Y: 104
         STA $E2         ; Memorize it
         JSR C3BC59      ; Actor's slot
         JSR C3BB60      ; Init sprite
         BRA C3BC4F      ; Skip a line
C3BC4C:  JSR C3BC52      ; Blank name
C3BC4F:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Blank challenger's name
C3BC52:  LDY #C3BD73     ; Text pointer
         JSR C30326      ; Draw 6 spaces
         RTS

; Get party actor indicated by cursor
C3BC59:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $69,X       ; Actor slot
         RTS

; Update "VS" symbol from Colosseum
C3BC60:  TAX             ; Index mode
         JMP (C3BC64,X)  ; Handle mode

; Jump table for the above
C3BC64:  dw C3BC68       ; Initialize sprite
         dw C3BC8B       ; Sustain sprite

; Mode 0: Initialize sprite
C3BC68:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #$ED11      ; Anim table ptr		=== SNES: D8/EC87
         STA $32C9,X     ; Set sprite's
         LDA #$0070      ; X: 112
         STA $33CA,X     ; Set sprite's
         LDA #$0060      ; Y: 96
         STA $344A,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         INC $3649,X     ; Mode +1
         LDA #$D8        ; Bank: D8
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3BC8B:  JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Load navigation data for Colosseum matchup menu
C3BC90:  LDY #C3BC9F     ; C3/BC9F
         JMP C30681      ; Load navig data

; Handle D-Pad for Colosseum matchup menu
C3BC96:  JSR C307B0      ; Handle D-Pad
C3BC99:  LDY #C3BCA4     ; C3/BCA4
         JMP C306C3      ; Relocate cursor

; Navigation data for Colosseum matchup menu
C3BC9F:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $04          ; 4 columns
         db $01          ; 1 row

; Cursor positions for Colosseum matchup menu
C3BCA4:  dw $B010        ; Member 1
         dw $B048        ; Member 2
         dw $B080        ; Member 3
         dw $B0B8        ; Member 4

; Window layout for Colosseum matchup menu
C3BCAC:  dw $588B,$020D  ; 15x4 at $588B (Prize)
C3BCB0:  dw $58A9,$020D  ; 15x4 at $58A9 (Bet)
C3BCB4:  dw $5CCB,$071C  ; 30x9 at $5CCB (Party)

; Load arena graphics, tilemap, and colors
C3BCB8:  REP #$20        ; 16-bit A
         LDA $E7168C     ; E8/0C49
         STA $F3         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA $E7168E     ; Bank: E8
         STA $F5         ; Set src HB
         JSR C3BD5F      ; Unpack GFX A
         LDY #$6800      ; $6800
         STY $2116       ; Set VRAM ptr
         LDY #$1000      ; End: 7E/C68C
         STY $E7         ; Set src end
         LDX $00         ; 1st: 7E/B68D
         JSR C3BD33      ; Upload GFX A

; Fork: Unpack and upload graphics for upper half
C3BCDB:  REP #$20        ; 16-bit A
         LDA $E71692     ; E8/1841
         STA $F3         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA $E71694     ; Bank: E8
         STA $F5         ; Set src HB
         JSR C3BD5F      ; Unpack GFX B
         LDY #$7000      ; $7000
         STY $2116       ; Set VRAM ptr
         LDY #$1000      ; End: 7E/C68C
         STY $E7         ; Set src end
         LDX $00         ; 1st: 7E/B68D
         JSR C3BD33      ; Upload GFX B

; Fork: Unpack battle tilemap, convert to menu format
C3BCFE:  REP #$20        ; 16-bit A
         LDA $E7187A     ; E7/652B
         STA $F3         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA #$E7        ; Bank: E7
         STA $F5         ; Set src HB
         JSR C3BD5F      ; Unpack map
         JSR C3BD45      ; Convert map

; Fork: Load colors
C3BD12:  REP #$20        ; 16-bit A
         LDA #$0AB0      ; E7/0AB0
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA #$E7        ; Bank: E7
         STA $E9         ; Set src HB
         LDX #$30C9      ; 7E/30C9
         STX $2181       ; Set WRAM LBs
         LDY $00         ; Index: 0
C3BD27:  LDA [$E7],Y     ; Color data
         STA $2180       ; To BG pal 4/5/6
         INY             ; Index +1
         CPY #$0060      ; Done 48 colors?
         BNE C3BD27      ; Loop if not
         RTS

; Upload current graphics set for arena background
C3BD33:  REP #$20        ; 16-bit A
C3BD35:  LDA $7EB68D,X   ; 8 px, 2 planes
         STA $2118       ; Save in VRAM
         INX             ; Index +1
         INX             ; Index +1
         CPX $E7         ; Past range?
         BNE C3BD35      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Convert and relocate decompressed arena tilemap
C3BD45:  LDX $00         ; Index: 0
         REP #$20        ; 16-bit A
C3BD49:  LDA $7EB68D,X   ; Attributes
         SEC             ; Prepare SBC
         SBC #$0380      ; Tile num -896
         STA $7E5949,X   ; Put in BG2a
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0580      ; Done 704?
         BNE C3BD49      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Decompress data for arena background
C3BD5F:  LDY #$B68D      ; 7E/B68D
         STY $F6         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $F8         ; Set dst HB
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         JSL $C2FF6D     ; Unpack data
         PLB             ; Restore DB
         RTS

; Positioned spaces for blanking challenger's name
C3BD73:  dw $7C35 : db "      ",$00			=== SNES: +40h as no diacritics

; Positioned Colosseum text, "Select the challenger"
C3BD7C:  dw $7D19 : db |ちょうせんしゃをきめてください[end]|		=== SNES: Shifted leftward but fails to add 40h (no diacritics)

; Positioned Colosseum text, "????????"
C3BD8E:  dw $7911 : db "????????", $00			=== SNES: Longer to match longer item names; shifted leftward

; Set to condense BG3 text in SwdTech naming menu	%%%
C3BD99:  LDX $00         ; Index: 0
C3BD9B:  LDA.L C3BDF3,X  ; BG3 V-Pan data
         STA $7E9BC9,X   ; Save in RAM
         INX             ; Index +1
         CPX #$000D      ; End of table?
         BNE C3BD9B      ; Loop if not
         LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #$9BC9      ; 7E/9BC9
         STY $4352       ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $4354       ; Set src HB
         LDA #$7E        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         LDA #$02        ; 1Rx2B to PPU
         STA $4360       ; Set DMA mode
         LDA #$11        ; $2111
         STA $4361       ; To BG3 H-Scroll
         LDY #C3BDE6     ; C3/BDE6
         STY $4362       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4364       ; Set src HB
         LDA #$C3        ; ...
         STA $4367       ; Set indir HB
         LDA #$40        ; Channel: 6
         TSB $43         ; Queue HDMA-6
         RTS

; BG3 H-Shift table for SwdTech naming menu (merges tilemaps)
C3BDE6:  db $4F,$00,$01  ; Title, desc
         db $50,$00,$00  ; Option rows 1-5
         db $30,$00,$00  ; Option rows 6-8
         db $10,$00,$01  ; Offscreen row
         db $00          ; End

; BG3 V-Shift table for SwdTech naming menu (condenses text)
C3BDF3:  db $4F,$02,$00  ; Title, desc
         db $50,$B0,$FF  ; Option rows 1-5
         db $30,$B0,$FF  ; Option rows 6-8
         db $10,$00,$00  ; Offscreen row
         db $00          ; End

; 3F: Initialize SwdTech naming menu
C3BE00:  JSR C335F7      ; Reset/Stop stuff
         JSR C37076      ; Reset BGs' X/Y
         LDA #$41        ; 64x32 at $4000
         STA $2109       ; Set BG3 map loc
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         STZ $4A         ; Char tbl index: 0
         STZ $5D         ; List cursor col: 1
         STZ $5F         ; List cursor row: 1
         JSR C3C07F      ; Load navig data
         JSR C3C088      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C3C123      ; Draw menu; VWF GFX
         LDA #$01        ; Min slot: 8
         LDY #C3C357     ; C3/C357
         JSR C311DE      ; Queue large arrow
         JSR C3BD99      ; Set to shift text
         LDA #$40        ; C3/BE37
         STA $27         ; Queue: Choice 1
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 40: Handle SwdTech naming choice 1
C3BE37:  JSR C3C033      ; Set to upload name
         JSR C3C085      ; Handle D-Pad
         JSR C3BF53      ; Handle L and R
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3BE67      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JSR C3C2F9      ; Create small arrow
         LDA $4D         ; Cursor column
         STA $5E         ; Set return loc
         LDA $4B         ; Cursor slot
         STA $28         ; Set altered slot
         JSR C3C09F      ; Load navig data
         LDA $5D         ; Former list column
         STA $4D         ; Set cursor column
         LDA $5F         ; Former list row
         STA $4E         ; Set cursor row
         JSR C3C0A8      ; Relocate cursor
         LDA #$41        ; C3/BE7A
         STA $26         ; Next: Choice 2
         RTS

; Fork: Handle Start
C3BE67:  LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BEQ C3BE79      ; Exit if not
C3BE6D:  JSR C30F1D      ; Sound: Click
         STZ $0205       ; Never read...
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
C3BE79:  RTS

; 41: Handle SwdTech naming choice 2
C3BE7A:  JSR C3C033      ; Set to upload name
         LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C3BE91      ; Branch if not
         LDA $4E         ; Cursor row
         CMP #$07        ; On bottom row?
         BNE C3BE91      ; Branch if not
         LDA #$4E        ; C3/BEEF
         STA $26         ; Next: Scroll
         LDA #$11        ; Frames: 17
         STA $20         ; Set scroll timer

; Fork: Handle upward scrolling
C3BE91:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C3BEA3      ; Branch if not
         LDA $4E         ; On top row?
         BNE C3BEA3      ; Skip if not
         LDA #$4F        ; C3/BF17
         STA $26         ; Next: Scroll
         LDA #$11        ; Frames: 17
         STA $20         ; Set scroll timer

; Fork: Handle L and R, plus intrapage navigation
C3BEA3:  JSR C3BF53      ; Handle L and R
         JSR C3C0A5      ; Handle D-Pad

; Fork: Handle Start
C3BEA9:  LDA $09         ; No-autofire keys
         BIT #$10        ; Pushing Start?
         BEQ C3BEB1      ; Branch if not
         BRA C3BE6D      ; Leave submenu

; Fork: Handle A
C3BEB1:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3BECB      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JSR C3BF3F      ; Replace letter
         LDA $5E         ; Altered letter
         CMP #$05        ; Rightmost?
         BEQ C3BEC6      ; Wrap if so
         INC A           ; Point to next
         BRA C3BEC7      ; Skip a line
C3BEC6:  TDC             ; Point to char 1
C3BEC7:  STA $5E         ; Set return pos
         BRA C3BED4      ; Next: Choice 1

; Fork: Handle B
C3BECB:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3BEEE      ; Exit if not
         JSR C30F14      ; Sound: Cursor

; Fork: Return to top of menu
C3BED4:  LDA $4D         ; Cursor column
         STA $5D         ; Set for return
         LDA $4E         ; Cursor row
         STA $5F         ; Set for return
         JSR C3C07F      ; Load navig data
         LDA $5E         ; Former position
         STA $4D         ; Set cursor column
         JSR C3C088      ; Relocate cursor
         LDA #$01        ; Mini arrow: Off
         TRB $46         ; Set menu flag
         LDA #$40        ; C3/BE37
         STA $26         ; Next: Choice 1
C3BEEE:  RTS

; 4E: Scroll to SwdTech naming page 2 if valid starting point
C3BEEF:  LDA $20         ; Timer expired?
         BEQ C3BF0C      ; Finalize if so
         LDA $4A         ; Bottom of P2?
         BNE C3BF12      ; Cancel if so
         REP #$20        ; 16-bit A
         LDA $7E9BCD     ; BG3 V-Shift
         CLC             ; Prepare ADC
         ADC #$0008      ; Go 8 px down
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
         RTS

; Fork: Resume control
C3BF0C:  LDA #$38        ; Chars per page
         STA $4A         ; Set page mod
         STZ $4E         ; Cursor row: 1
C3BF12:  LDA #$41        ; C3/BE37
         STA $26         ; Next: Choice 1
         RTS

; 4F: Scroll to SwdTech naming page 1 if valid starting point
C3BF17:  LDA $20         ; Timer expired?
         BEQ C3BF34      ; Finalize if so
         LDA $4A         ; Top of page 1?
         BEQ C3BF3A      ; Cancel if so
         REP #$20        ; 16-bit A
         LDA $7E9BCD     ; BG3 V-Shift
         SEC             ; Prepare SBC
         SBC #$0008      ; Go 8 px up
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
         RTS

; Fork: Restore control
C3BF34:  STZ $4A         ; Char tbl index
         LDA #$07        ; Row: 8th
         STA $4E         ; Set cursor's
C3BF3A:  LDA #$41        ; C3/BE37
         STA $26         ; Next: Choice 1
         RTS

; Replace character in SwdTech name
C3BF3F:  JSR C3C06E      ; Name data index
         TXA             ; ...
         CLC             ; Prepare ADC
         ADC $28         ; Get altered slot
         TAX             ; Index it
         LDA $4B         ; Cursor slot
         CLC             ; ...
         ADC #$80        ; Add base char
         CLC             ; ...
         ADC $4A         ; +56 if page 2
         STA $1CF8,X     ; Replace char
         RTS

; Handle L and R in SwdTech naming menu
C3BF53:  LDA $08         ; No-autofire keys
         BIT #$10        ; Pushing R?
         BNE C3BF5D      ; Branch if so
         BIT #$20        ; Pushing L?
         BEQ C3BF77      ; Exit if not
C3BF5D:  JSR C30F0E      ; Sound: Cursor
         LDA $4A         ; On page 2?
         BNE C3BF78      ; Branch if so

; Fork: Switch to page 2
C3BF64:  LDA #$38        ; Chars per page
         STA $4A         ; Set tbl index
         REP #$20        ; 16-bit A
         LDA #$0030      ; BG3 V-Shift: 48
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
C3BF77:  RTS

; Fork: Switch to page 1
C3BF78:  STZ $4A         ; Char tbl index
         REP #$20        ; 16-bit A
         LDA #$FFB0      ; BG3 V-Shift: -80
         STA $7E9BCD     ; For upper chars
         STA $7E9BD0     ; For lower chars
         SEP #$20        ; 8-bit A
         RTS

; Build description tilemap for SwdTech naming menu
C3BF8A:  LDX #$8049      ; Base: 7E/8049
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$01B0      ; Ends at 24, 7
         STY $E7         ; Set row's limit
         LDY #$0186      ; Starts at 4, 7
         LDX #$3680      ; Tile 640, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Build row 1
         LDY #$01F0      ; Ends at 24, 8
         STY $E7         ; Set row's limit
         LDY #$01C6      ; Starts at 4, 8
         LDX #$3681      ; Tile 641, pal 5
         STX $E0         ; Priority enabled
         JMP C3B0C6      ; Build row 2

; Load and upload VWF description graphics for renamed SwdTech
C3BFB3:  LDY #$0280      ; Bytes: 640
         STY $F3         ; Set buffer size
         JSR C3C2CD      ; Clear GFX buffer
         LDX #$FFAE      ; CF/FFAE
         STX $E7         ; Set ptr loc LBs
         LDX #$FD00      ; CF/FD00
         STX $EB         ; Set text loc LBs
         LDA #$CF        ; Bank: CF
         STA $E9         ; Set ptr loc HB
         LDA #$CF        ; ...
         STA $ED         ; Set text loc HB
         LDX #$9EC9      ; 7E/9EC9
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         LDA $0201       ; SwdTech
         JSR C35D99      ; Load description
         STZ $8D         ; String width: 0
         STZ $ED         ; VRAM index LB: 0
         STZ $EE         ; VRAM index HB: 0
         LDX $00         ; Char index: 0
C3BFE2:  LDA $7E9EC9,X   ; Name character
         BEQ C3BFF3      ; If terminator
         JSR C3B1EC      ; Decode char			=== SNES: Only one font bank
         PHX             ; Save index
         JSR C3B227      ; Load graphics
         PLX             ; Char index
         INX             ; Char index +1
         BRA C3BFE2      ; Do next char

; Fork: Upload description graphics
C3BFF3:  LDY #$7400      ; $7400
         STY $1B         ; Set VRAM ptr
         LDY #$A271      ; 7E/A271
         STY $1D         ; Set src LBs
         LDY #$0700      ; Bytes: 1792
         STY $19         ; Set data size
         JSR C31517      ; Upload graphics
         STZ $1B         ; Null VRAM ptr LB
         STZ $1C         ; Null VRAM ptr HB
         RTS

; Build tilemap for name of renamed SwdTech
C3C00A:  LDX #$8049      ; Base: 7E/8049
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDY #$00B0      ; Ends at 24, 3
         STY $E7         ; Set row's limit
         LDY #$009E      ; Starts at 16, 3
         LDX #$3600      ; Tile 512, pal 5
         STX $E0         ; Priority enabled
         JSR C3B0C6      ; Build row 1
         LDY #$00F0      ; Ends at 24, 4
         STY $E7         ; Set row's limit
         LDY #$00DE      ; Starts at 16, 4
         LDX #$3601      ; Tile 513, pal 5
         STX $E0         ; Priority enabled
         JMP C3B0C6      ; Build row 2

; Load and set to upload VWF string graphics for renamed SwdTech
C3C033:  LDY #$0120      ; Bytes: 288
         STY $F3         ; Set buffer size
         JSR C3C2CD      ; Clear GFX buffer
         STZ $8D         ; String width: 0
         STZ $ED         ; VRAM index LB: 0
         STZ $EE         ; VRAM index HB: 0
         LDA #$06        ; Letters: 6
         STA $F1         ; Set counter
         JSR C3C06E      ; Define X
C3C048:  LDA $1CF8,X     ; Name letter
         LDY #$3F40      ; Base: C4/D400
         STY $EB         ; Set font index
         PHX             ; Save char index
         JSR C3B227      ; Load graphics
         PLX             ; Char index
         INX             ; Char index +1
         DEC $F1         ; One less char
         BNE C3C048      ; Loop till last
         LDY #$7000      ; $7000
         STY $1B         ; Set VRAM ptr
         LDY #$A271      ; 7E/A271
         STY $1D         ; Set src LBs
         LDY #$0120      ; Bytes: 288
         STY $19         ; Set data size
         LDA #$01        ; CGRAM: Freeze
         TRB $45         ; Set NMI flag
         RTS

; Compute SwdTech name data index
C3C06E:  TDC             ; Clear A
         LDA $0201       ; SwdTech
         ASL A           ; x2
         ASL A           ; x4
         STA $E0         ; Memorize it
         LDA $0201       ; SwdTech
         ASL A           ; x2
         CLC             ; ...
         ADC $E0         ; x6 letters
         TAX             ; Index it
         RTS

; Load navigation data for name area in SwdTech naming menu
C3C07F:  LDY #C3C08E     ; C3/C08E
         JMP C30681      ; Load navig data

; Handle D-Pad for name area in SwdTech naming menu
C3C085:  JSR C307B0      ; Handle D-Pad
C3C088:  LDY #C3C093     ; C3/C093
         JMP C306C3      ; Relocate cursor

; Navigation data for name area in SwdTech naming menu
C3C08E:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $06          ; 6 columns
         db $01          ; 1 row

; Cursor positions for name in SwdTech naming menu
C3C093:  dw $1C70        ; Letter 1
         dw $1C7C        ; Letter 2
         dw $1C88        ; Letter 3
         dw $1C94        ; Letter 4
         dw $1CA0        ; Letter 5
         dw $1CAC        ; Letter 6

; Load navigation data for SwdTech naming menu options
C3C09F:  LDY #C3C0AE     ; C3/C0AE
         JMP C30681      ; Load navig data

; Handle D-Pad for SwdTech naming menu options
C3C0A5:  JSR C307B0      ; Handle D-Pad
C3C0A8:  LDY #C3C0B3     ; C3/C0B3
         JMP C306C3      ; Relocate cursor

; Navigation data for SwdTech naming menu options
C3C0AE:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $07          ; 7 columns
         db $08          ; 8 rows

; Cursor positions for SwdTech naming menu options
C3C0B3:  dw $5010        ; Row 1, column 1
         dw $5030        ; Row 1, column 2
         dw $5050        ; Row 1, column 3
         dw $5070        ; Row 1, column 4
         dw $5090        ; Row 1, column 5
         dw $50B0        ; Row 1, column 6
         dw $50D0        ; Row 1, column 7
         dw $6010        ; Row 2, column 1
         dw $6030        ; Row 2, column 2
         dw $6050        ; Row 2, column 3
         dw $6070        ; Row 2, column 4
         dw $6090        ; Row 2, column 5
         dw $60B0        ; Row 2, column 6
         dw $60D0        ; Row 2, column 7
         dw $7010        ; Row 3, column 1
         dw $7030        ; Row 3, column 2
         dw $7050        ; Row 3, column 3
         dw $7070        ; Row 3, column 4
         dw $7090        ; Row 3, column 5
         dw $70B0        ; Row 3, column 6
         dw $70D0        ; Row 3, column 7
         dw $8010        ; Row 4, column 1
         dw $8030        ; Row 4, column 2
         dw $8050        ; Row 4, column 3
         dw $8070        ; Row 4, column 4
         dw $8090        ; Row 4, column 5
         dw $80B0        ; Row 4, column 6
         dw $80D0        ; Row 4, column 7
         dw $9010        ; Row 5, column 1
         dw $9030        ; Row 5, column 2
         dw $9050        ; Row 5, column 3
         dw $9070        ; Row 5, column 4
         dw $9090        ; Row 5, column 5
         dw $90B0        ; Row 5, column 6
         dw $90D0        ; Row 5, column 7
         dw $A010        ; Row 6, column 1
         dw $A030        ; Row 6, column 2
         dw $A050        ; Row 6, column 3
         dw $A070        ; Row 6, column 4
         dw $A090        ; Row 6, column 5
         dw $A0B0        ; Row 6, column 6
         dw $A0D0        ; Row 6, column 7
         dw $B010        ; Row 7, column 1
         dw $B030        ; Row 7, column 2
         dw $B050        ; Row 7, column 3
         dw $B070        ; Row 7, column 4
         dw $B090        ; Row 7, column 5
         dw $B0B0        ; Row 7, column 6
         dw $B0D0        ; Row 7, column 7
         dw $C010        ; Row 8, column 1
         dw $C030        ; Row 8, column 2
         dw $C050        ; Row 8, column 3
         dw $C070        ; Row 8, column 4
         dw $C090        ; Row 8, column 5
         dw $C0B0        ; Row 8, column 6
         dw $C0D0        ; Row 8, column 7

; Draw SwdTech naming menu, upload kanji graphics
C3C123:  LDY #C3C238     ; C3/C238
         JSR C303C4      ; Draw top box
         LDY #C3C23C     ; C3/C23C
         JSR C303C4      ; Draw middle box
         LDY #C3C240     ; C3/C240
         JSR C303C4      ; Draw bottom box
         JSR C30EBD      ; Upload windows
         JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C3C1F2      ; Draw gauge
         JSR C3C1CA      ; Draw tech number
         JSR C30E93      ; Upload BG1 A+B

; Fork: Build tilemap for character set
C3C147:  JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDX #$7849      ; Base: 7E/7849
         STX $EB         ; Set map ptr LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set ptr HB
         LDX $00         ; ROM index: 0
C3C15C:  REP #$20        ; 16-bit A
         LDA.L C3C18A,X  ; Tilemap index
         TAY             ; Index it
         INX             ; ROM index +1
         INX             ; ROM index +1
         LDA.L C3C18A,X  ; Base attribs
         INX             ; ROM index +1
         INX             ; ROM index +1
         PHX             ; Memorize it
         TAX             ; X = Attribs
         JSR C3C25A      ; Draw 7 chars
         PLX             ; ROM index
         CPX #$0040      ; Done 8x2 rows?
         BNE C3C15C      ; Loop if not

; Fork: Upload graphics and tilemaps
C3C176:  SEP #$20        ; 8-bit A
         JSR C3C2A5      ; Load charset GFX
         JSR C3BF8A      ; Build desc map
         JSR C3BFB3      ; Upload desc GFX
         JSR C3C00A      ; Build name map
         JSR C3C033      ; Queue name GFX DMA
         JMP C30ED9      ; Upload BG3 A+B

; Base position and attributes for charset in SwdTech naming menu
C3C18A:  dw $0008,$3400  ; Page 1, row 1
         dw $0088,$341C  ; Page 1, row 2
         dw $0108,$3438  ; Page 1, row 3
         dw $0188,$3454  ; Page 1, row 4
         dw $0208,$3470  ; Page 1, row 5
         dw $0288,$348C  ; Page 1, row 6
         dw $0308,$34A8  ; Page 1, row 7
         dw $0388,$34C4  ; Page 1, row 8
         dw $0408,$34E0  ; Page 2, row 1
         dw $0488,$34FC  ; Page 2, row 2
         dw $0508,$3518  ; Page 2, row 3
         dw $0588,$3534  ; Page 2, row 4
         dw $0608,$3550  ; Page 2, row 5
         dw $0688,$356C  ; Page 2, row 6
         dw $0708,$3588  ; Page 2, row 7
         dw $0788,$35A4  ; Page 2, row 8

; Draw "SwdTech <#>" in SwdTech naming menu
C3C1CA:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         LDY #C3C251     ; Text pointer
         JSR C30326      ; Draw "SwdTech"
         TDC             ; Clear A
         LDA $0201       ; SwdTech
         INC A           ; Now 1-8
         CLC             ; Prepare ADC
         ADC #$53        ; Turn into text
         STA $F9         ; Add to string
         STZ $FA         ; End string
         LDX #$38DD      ; Tilemap ptr
         STX $F7         ; Set position
         LDY #$00F7      ; 00/00F7
         STY $E7         ; Set src LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw value
         RTS

; Draw gauge in SwdTech naming menu
C3C1F2:  LDA #$30        ; Palette 4
         STA $29         ; Color: Gray
         LDY #C3C244     ; Text pointer
         JSR C302F9      ; Draw gauge
         TDC             ; Clear A
         LDA $0201       ; SwdTech
         BEQ C3C230      ; If Dispatch
         TAY             ; Set counter
         REP #$20        ; 16-bit A
         LDA #$3911      ; Tilemap ptr
         STA $7E9E89     ; Set position
         SEP #$20        ; 8-bit A
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Index: 0
C3C216:  LDA.L C3C231,X  ; Filler tile
         STA $2180       ; Add to string
         INX             ; Index +1
         DEY             ; One less left
         BNE C3C216      ; Loop till last
         STZ $2180       ; End string
         LDY #$9E89      ; 7E/9E89
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         JSR C302FF      ; Draw filling
C3C230:  RTS

; Tile numbers for filling SwdTech gauge
C3C231:  db $18          ; Retort
         db $18          ; Slash
         db $18          ; Quadra Slam
         db $18          ; Empowerer
         db $18          ; Stunner
         db $18          ; Quadra Slice
         db $18          ; Cleave

; Window layout for SwdTech naming menu
C3C238:  dw $588B,$021C  ; 30x04 at $588B (Top)
C3C23C:  dw $598B,$021C  ; 30x04 at $598B (Middle)
C3C240:  dw $5A8B,$101C  ; 30x18 at $5A8B (Bottom)

; Positioned text for SwdTech naming menu
C3C244:  dw $390D : db "«¤±±±±±±±»",$00
C3C251:  dw $388F : db |ひっさつけん[end]|		; SwdTech

; Build tilemap for current row of kanji in SwdTech naming menu
C3C25A:  SEP #$20        ; 8-bit A
         LDA #$07        ; Characters: 7
         STA $E2         ; Set counter
C3C260:  REP #$20        ; 16-bit A
         PHY             ; Save map index
         PHX             ; Save attributes
         JSR C3C27C      ; Draw character
         PLX             ; Tile attributes
         TXA             ; Put them in A
         CLC             ; Prepare ADC
         ADC #$0004      ; Base tile num +4
         TAX             ; Put this in X
         PLY             ; Tilemap index
         TYA             ; Put it in A
         CLC             ; Prepare ADC
         ADC #$0008      ; Go 4 tiles right
         TAY             ; Reindex it
         SEP #$20        ; 8-bit A
         DEC $E2         ; One less char
         BNE C3C260      ; Loop till last
         RTS

; Build tilemap for current kanji from charset in SwdTech naming menu
C3C27C:  STX $E0         ; Save attributes
         LDA $E0         ; Put them in A
         STA [$EB],Y     ; Set NW tile's
         INC $E0         ; Tile number +1
         INC $E0         ; Tile number +1
         INY             ; Map index +1
         INY             ; Map index +1
         LDA $E0         ; Tile attributes
         STA [$EB],Y     ; Set NE tile's
         DEC $E0         ; Tile number -1
         DEY             ; Map index -1
         DEY             ; Map index -1
         TYA             ; Put it in A
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         TAY             ; Reindex it
         LDA $E0         ; Tile attributes
         STA [$EB],Y     ; Set SW tile's
         INY             ; Map index +1
         INY             ; Map index +1
         INC $E0         ; Tile number +1
         INC $E0         ; Tile number +1
         LDA $E0         ; Tile attributes
         STA [$EB],Y     ; Set SE tile's
         RTS

; Load VWF graphics for charset in SwdTech naming menu
C3C2A5:  STZ $E4         ; Char slot: 1st
         LDY #$6000      ; $6000
         STY $F1         ; Set VRAM ptr
C3C2AC:  JSR C3C2DE      ; Load char GFX
         LDY $F1         ; VRAM pointer
         JSR C3AF53      ; Upload graphics
         REP #$20        ; 16-bit A
         LDA $F1         ; VRAM pointer
         CLC             ; Prepare ADC
         ADC #$0020      ; Skip 4 tiles
         STA $F1         ; Save changes
         SEP #$20        ; 8-bit A
         INC $E4         ; Char slot +1
         LDA $E4         ; Char slot
         CMP #$70        ; Done all 112?
         BNE C3C2AC      ; Loop if not
         STZ $1B         ; Null VRAM ptr LB
         STZ $1C         ; Null VRAM ptr HB
         RTS

; Clear buffer for storing element or SwdTech kanji graphics (4 tiles)	=== SNES: Only elements
C3C2CD:  TDC             ; Clear A
         TAX             ; Index: 0
         REP #$20        ; 16-bit A
C3C2D1:  STA $7EA271,X   ; Clear a word
         INX             ; Index +1
         INX             ; Index +1
         CPX $F3         ; Past range?
         BNE C3C2D1      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Load VWF graphics for charset slot in SwdTech naming menu	%%%
C3C2DE:  LDY #$0040      ; Bytes: 64
         STY $F3         ; Set buffer size
         JSR C3C2CD      ; Clear GFX buffer
         STZ $8D         ; String width: 0
         STZ $ED         ; VRAM index LB: 0
         STZ $EE         ; VRAM index HB: 0
         LDA $E4         ; Slot number
         CLC             ; Prepare ADC
         ADC #$80        ; Now tile number
         LDY #$3F40      ; Base: C4/D400
         STY $EB         ; Set font index
         JMP C3B227      ; Load graphics

; Create small arrow in SwdTech naming menu
C3C2F9:  LDA #$02        ; Min slot: 16
         LDY #C3C312     ; C3/C312
         JSR C311DE      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA $55         ; Cursor's X
         STA $7E33CA,X   ; Set arrow's
         LDA $57         ; Cursor's Y
         STA $7E344A,X   ; Set arrow's
         SEP #$20        ; 8-bit A
         RTS

; Update small arrow in SwdTech naming menu
C3C312:  TAX             ; Index mode
         JMP (C3C316,X)  ; Handle mode

; Jump table for the above
C3C316:  dw C3C31A       ; Initialize arrow
         dw C3C335       ; Sustain arrow

; Mode 0: Initialize arrow
C3C31A:  LDX $2D         ; Queue index
         LDA #$01        ; Show arrow: Y
         TSB $46         ; Set menu flag
         REP #$20        ; 16-bit A
         LDA #C3C34E     ; Anim table ptr
         STA $32C9,X     ; Set arrow's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         INC $3649,X     ; Mode +1

; Mode 1: Sustain arrow
C3C335:  LDA $46         ; Menu flags
         BIT #$01        ; Delete arrow?
         BEQ C3C342      ; Dequeue if so
         LDX $2D         ; Queue index
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C3C342:  CLC             ; Set to dequeue
         RTS

; OAM for small white arrow in naming menus		=== SNES: Only actor naming menu (also below)
C3C344:  db $01          ; Tiles: 1
         dw $0009        ; 8x8, X+9, Y+0
         dw $3E02        ; Tile 2, pal 7, prio 3

; OAM for small black arrow in naming menus
C3C349:  db $01          ; Tiles: 1
         dw $0009        ; 8x8, X+9, Y+0
         dw $3E12        ; Tile 18, pal 7, prio 3

; Animation table for small arrow in naming menus
C3C34E:  dw C3C344       ; White arrow
         db $02          ; Frames: 2
         dw C3C349       ; Black arrow
         db $02          ; Frames: 2
         dw C3C344       ; Bogus...
         db $FF          ; Loop

; Update large arrow in SwdTech naming menu
C3C357:  TAX             ; Index mode
         JMP (C3C35B,X)  ; Handle mode

; Jump table for the above
C3C35B:  dw C3C35F       ; Initialize arrow
         dw C3C382       ; Sustain arrow

; Mode 0: Initialize arrow
C3C35F:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #C3C3A3     ; Anim table ptr
         STA $32C9,X     ; Set arrow's
         LDA #$0078      ; X: 120
         STA $33CA,X     ; Set arrow's
         LDA #$0048      ; Base Y: 72
         STA $344A,X     ; Set arrow's
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $35CA,X     ; Set ptr HB
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer

; Mode 1: Sustain arrow
C3C382:  LDX $2D         ; Queue index
         LDA $4A         ; On first page?
         BEQ C3C38C      ; Branch if so
         LDA #$02        ; Arrow: Up
         BRA C3C38D      ; Skip a line
C3C38C:  TDC             ; Arrow: Down
C3C38D:  TXY             ; Queue index
         TAX             ; Pointer index
         REP #$20        ; 16-bit A
         LDA.L C3C39F,X  ; Anim table ptr
         STA $32C9,Y     ; Set arrow's
         SEP #$20        ; 8-bit A
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Pointers for SwdTech naming menu's large arrows
C3C39F:  dw C3C3A3       ; Downward arrow
         dw C3C3AC       ; Upward arrow

; Animation table for large downward arrow in SwdTech naming menu
C3C3A3:  dw C3C3B5       ; Hide arrow
         db $10          ; Frames: 16
         dw C3C3B6       ; Show arrow
         db $10          ; Frames: 16
         dw C3C3B5       ; Bogus...
         db $FF          ; Loop

; Animation table for large upward arrow in SwdTech naming menu
C3C3AC:  dw C3C3B5       ; Hide arrow
         db $10          ; Frames: 16
         dw C3C3BB       ; Show arrow
         db $10          ; Frames: 16
         dw C3C3B5       ; Bogus...
         db $FF          ; Loop

; OAM for blanking large page arrow			=== SNES: Only Config menu
C3C3B5:  db $00          ; Tiles: 0

; OAM for large downward arrow in SwdTech naming menu
C3C3B6:  db $01          ; Tiles: 1
         dw $8280        ; 16x16, X+0, Y+130
         dw $3E03        ; Tile 3, pal 7, prio 3

; OAM for large upward arrow
C3C3BB:  db $01          ; Tiles: 1
         dw $0080        ; 16x16, X+0, Y+0
         dw $BE03        ; Tile 3, pal 7, prio 3, V-Flip

; 24: Initialize shop menu
C3C3C0:  JSR C335F7      ; Reset/Stop stuff
         JSR C37076      ; Reset BGs' X/Y

         LDA #$03        ; 64x64 at $0000
         STA $2107       ; Set BG1 map loc
         LDA #$C0        ; Channels: 6, 7
         TRB $43         ; Halt HDMA 6+7...
         LDA #$02        ; Main cursor: On
         STA $46         ; Bar/Blinker: Off
         STZ $4A         ; Sell list scroll: 0
         JSR C3C7DD      ; Load navig data
         JSR C3C7E6      ; Relocate cursor
         JSR C30833      ; Queue cursor OAM
         JSR C3C81B      ; Draw menu; desc
         JSR C385DA      ; Set to shift text
C3C3E4:  JSR C3CF73      ; Adjust BG3 shifting
         LDA #$25        ; C3/C3F2
         STA $27         ; Queue: Sustain menu
         LDA #$01        ; C3/1DE4
         STA $26         ; Next: Fade-in
         JMP C33609      ; BRT:1 + NMI

; 25: Sustain main shop menu
C3C3F2:  JSR C3C7E3      ; Handle D-Pad
         LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3C401      ; Branch if not
         JSR C30F1D      ; Sound: Click
         JMP C3C6E9      ; Handle choice

; Fork: Handle B
C3C401:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3C413      ; Exit if not
         JSR C30F14      ; Sound: Cursor
C3C40A:  STZ $0205       ; Never read...
         LDA #$FF        ; Null value
         STA $27         ; Queue menu exit
         STZ $26         ; Next: Fade-out
C3C413:  RTS

; 26: Handle buy item list
C3C414:  LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         JSR C30FA4      ; Queue text upload
         JSR C3C7FD      ; Handle D-Pad
         JSR C3CBDF      ; Draw qty owned
         JSR C3CC03      ; Draw qty worn

; Fork: Handle B
C3C424:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3C430      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JMP C3C6B7      ; Exit submenu

; Fork: Handle A
C3C430:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3C43C      ; Exit if not
         JSR C3C786      ; Set buy limit
         JSR C3C73D      ; Test GP, stock
C3C43C:  RTS

; Set description to be displayed and to ignore joypad
C3C43D:  LDA #$10        ; Description: On
         TRB $45         ; Set menu flag
         LDA #$20        ; D-Pad: Ignore
         TSB $45         ; Set desc flag
         RTS

; Load item description for Buy menu
C3C446:  JSR C38A89      ; Set desc ptrs
         JSR C3CF1D      ; Selected item
         JMP C35D95      ; Load description

; Load item description for Sell menu
C3C44F:  JSR C38A89      ; Set desc ptrs
         TDC             ; Clear A
         LDA $4B         ; Selected slot
         TAX             ; Index it
         LDA $1869,X     ; Item in slot
         JMP C35D95      ; Load description

; 27: Handle buy order menu
C3C45C:  JSR C3C43D      ; Set desc flags
         JSR C3C446      ; Load description
         JSR C3CAAA      ; Get order value
         JSR C3CB05      ; Draw size, value

; Fork: Buy quantity +1
C3C468:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3C490      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA $28         ; Buy quantity
         CMP $6A         ; At capacity?
         BEQ C3C4D3      ; Abort if so
         INC $28         ; Quantity +1
         JSR C3CAAA      ; Get new cost
         LDA $1860       ; Gold LB
         CMP $F1         ; C- if < cost's
         LDA $1861       ; Gold MB
         SBC $F2         ; C- if < cost's
         LDA $1862       ; Gold HB
         SBC $F3         ; So, GP < cost?
         BCS C3C48F      ; Exit if not
         DEC $28         ; Quantity -1
C3C48F:  RTS

; Fork: Buy quantity -1
C3C490:  LDA $0B         ; Semi-auto keys
         BIT #$02        ; Pushing left?
         BEQ C3C4A1      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA $28         ; Buy quantity
         CMP #$01        ; One?
         BEQ C3C4F5      ; Abort if so
         DEC $28         ; Quantity -1

; Fork: Buy quantity +10
C3C4A1:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C3C4DA      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA #$0A        ; Quantity: 10
         CLC             ; Prepare ADC
         ADC $28         ; Add order size
         CMP $6A         ; At capacity?
         BEQ C3C4B5      ; Retain if so
         BCS C3C4D6      ; Abort if over
C3C4B5:  STA $28         ; Set order size
         JSR C3CAAA      ; Get new cost
         LDA $1860       ; Gold LB
         CMP $F1         ; C- if < cost's
         LDA $1861       ; Gold MB
         SBC $F2         ; C- if < cost's
         LDA $1862       ; Gold HB
         SBC $F3         ; So, GP < cost?
         BCS C3C4D2      ; Exit if not
         LDA $28         ; Buy quantity
         SEC             ; Prepare SBC
         SBC #$0A        ; Subtract 10
         STA $28         ; Save changes
C3C4D2:  RTS

; Fork: Go to handler for B
C3C4D3:  JMP C3C4F5      ; Handle B

; Fork: Leave quantity unchanged...
C3C4D6:  LDA $28         ; Buy quantity
         BRA C3C4B5      ; Test cost

; Fork: Buy quantity -10
C3C4DA:  LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C3C4F5      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA $28         ; Buy quantity
         SEC             ; Prepare SBC
         SBC #$0A        ; Subtract 10
         BMI C3C4F1      ; Use 1 if < 0
         CMP #$01        ; Down to zero?
         BCC C3C4F5      ; Abort if so
         STA $28         ; Save changes
         RTS

; Fork: Set buy quantity to 1
C3C4F1:  LDA #$01        ; Quantity: 1
         STA $28         ; Set order size

; Fork: Handle B
C3C4F5:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3C501      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JMP C3C70A      ; Exit submenu

; Fork: Handle A
C3C501:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3C50D      ; Exit if not
         JSR C30F39      ; Sound: Cash
         JSR C3C50E      ; ...
C3C50D:  RTS             ; ...
C3C50E:  JSR C3CF1D      ; Bought item
         LDY $00         ; Item slot: 1
C3C513:  CMP $1869,Y     ; Slot holds it?
         BEQ C3C538      ; Qty +1 if so
         INY             ; Item slot +1
         CPY #$0100      ; Done all 256?
         BNE C3C513      ; Loop if not
         LDY $00         ; Item slot: 1
C3C520:  LDA $1869,Y     ; Item in slot
         CMP #$FF        ; None?
         BEQ C3C52A      ; Overwrite if so
         INY             ; Item slot +1
         BRA C3C520      ; Try next slot

; Fork: Put bought item in empty slot
C3C52A:  LDA $28         ; Quantity bought
         STA $1969,Y     ; Assign to slot
         LDA $7E9D89,X   ; Bought item
         STA $1869,Y     ; Assign to slot
         BRA C3C541      ; Reduce GP, etc.

; Fork: Add quantity bought to stock
C3C538:  LDA $28         ; Quantity bought
         CLC             ; Prepare ADC
         ADC $1969,Y     ; Add qty owned
         STA $1969,Y     ; Set qty owned

; Fork: Reduce party's GP, leave submenu
C3C541:  JSR C3CAAA      ; Get order value
         SEC             ; Prepare SBC
         LDA $1860       ; Gold LB
         SBC $F1         ; Deduct cost's
         STA $1860       ; Save changes
         REP #$20        ; 16-bit A
         LDA $1861       ; Gold HBs
         SBC $F2         ; Deduct cost's
         STA $1861       ; Save changes
         SEP #$20        ; 8-bit A
         JSR C33369      ; Cap GP
         LDY #C3D327     ; Text pointer
         JSR C30326      ; Draw "Bye!"
         JMP C3C7D4      ; Set to exit

; 28: Return to Buy menu after delay
C3C565:  LDA $20         ; Delay expired?
         BNE C3C56C      ; Exit if not
         JSR C3C70A      ; Leave submenu
C3C56C:  RTS

; 29: Handle sell item list
C3C56D:  LDA #$10        ; Reset/Stop desc
         TSB $45         ; Set menu flag
         TDC             ; Clear A
         STA $2A         ; List type: Stock
         JSR C30F68      ; Queue list upload
         JSR C31FCA      ; Handle L and R
         BCS C3C5CC      ; Exit if pushed
         JSR C384A9      ; Handle D-Pad

; Fork: Handle B
C3C57F:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3C58B      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         JMP C3C6B7      ; Exit submenu

; Fork: Handle A
C3C58B:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3C5CC      ; Exit if not
         JSR C3CF26      ; Selected item
         CMP #$FF        ; Empty slot?
         BEQ C3C5C6      ; Fail if so
         JSR C30F1D      ; Sound: Click
         LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         JSR C371A9      ; Blank item list
         JSR C30F68      ; Set to upload it
         JSR C313D3      ; Upload it now
         LDA #$2A        ; C3/C5CD
         STA $26         ; Next: Order menu
         LDX #$0008      ; X: 8
         STX $55         ; Set cursor's
         LDX #$0034      ; Y: 52
         STX $57         ; Set cursor's
         JSR C3CA02      ; Draw blue text
         JSR C3CA30      ; Draw item info
         LDY #C3D316     ; Text pointer
         JSR C30326      ; Draw "How many?"
         JSR C3C7C4      ; Switch screen
         RTS

; Fork: Invalid selection
C3C5C6:  JSR C30F2B      ; Play buzzer
         JSR C330F8      ; Pixelate screen
C3C5CC:  RTS

; 2A: Handle sell order menu
C3C5CD:  JSR C3C43D      ; Set desc flags
         JSR C3C44F      ; Load description
         JSR C3CABC      ; Get order value
         JSR C3CB0E      ; Draw qty, offer

; Fork: Sell quantity +1
C3C5D9:  LDA $0B         ; Semi-auto keys
         BIT #$01        ; Pushing right?
         BEQ C3C5EC      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA $28         ; Sell quantity
         CMP $64         ; Can sell more?
         BEQ C3C637      ; Abort if not
         INC $28         ; Quantity +1
         BRA C3C637      ; Handle B

; Fork: Sell quantity -1
C3C5EC:  LDA $0B         ; Semi-auto keys
         BIT #$02        ; Pushing left?
         BEQ C3C5FD      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA $28         ; Sell quantity
         CMP #$01        ; One?
         BEQ C3C637      ; Abort if so
         DEC $28         ; Quantity -1

; Fork: Sell quantity +10
C3C5FD:  LDA $0B         ; Semi-auto keys
         BIT #$08        ; Pushing up?
         BEQ C3C61B      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA #$0A        ; Quantity: 10
         CLC             ; Prepare ADC
         ADC $28         ; Add order size
         CMP $64         ; Owning enough?
         BEQ C3C615      ; ...
         BCS C3C615      ; Limit if not
         STA $28         ; Set order size
         BRA C3C637      ; Handle B

; Fork: Limit sell quantity
C3C615:  LDA $64         ; Quantity owned
         STA $28         ; Set order size
         BRA C3C637      ; Handle B

; Fork: Sell quantity -10
C3C61B:  LDA $0B         ; Semi-auto keys
         BIT #$04        ; Pushing down?
         BEQ C3C637      ; Branch if not
         JSR C30F0E      ; Sound: Cursor
         LDA $28         ; Sell quantity
         SEC             ; Prepare SBC
         SBC #$0A        ; Subtract 10
         BMI C3C633      ; Use 1 if < 0
         CMP #$01        ; Down to zero?
         BCC C3C637      ; Abort if so
         STA $28         ; Save changes
         BRA C3C637      ; Handle B

; Fork: Set sell quantity to 1
C3C633:  LDA #$01        ; Quantity: 1
         STA $28         ; Set order size

; Fork: Handle B
C3C637:  LDA $09         ; No-autofire keys
         BIT #$80        ; Pushing B?
         BEQ C3C652      ; Branch if not
         JSR C30F14      ; Sound: Cursor
         LDX $00         ; Clear X
         STX $39         ; BG2 X-Pos: 0
         STX $3B         ; BG2 Y-Pos: 0
         JSR C3C8B7      ; Clean up BG3
         LDY #C3D27E     ; Text pointer
         JSR C30326      ; Draw options
         JMP C3C726      ; Exit submenu

; Fork: Handle A
C3C652:  LDA $08         ; No-autofire keys
         BIT #$80        ; Pushing A?
         BEQ C3C65E      ; Exit if not
         JSR C30F39      ; Sound: Cash
         JSR C3C65F      ; ...
C3C65E:  RTS             ; ...
C3C65F:  JSR C3CABC      ; Get order value
         CLC             ; Prepare ADC
         LDA $1860       ; Gold LB
         ADC $F1         ; Add cost's
         STA $1860       ; Save changes
         REP #$20        ; 16-bit A
         LDA $1861       ; Gold HBs
         ADC $F2         ; Add cost's + C
         STA $1861       ; Save changes
         SEP #$20        ; 8-bit A
         LDA $64         ; Quantity owned
         CMP $28         ; Sold all of it?
         BEQ C3C68B      ; Branch if so
         JSR C3CF26      ; Define Y
         LDA $1969,Y     ; Quantity owned
         SEC             ; Prepare SBC
         SBC $28         ; Deduct qty sold
         STA $1969,Y     ; Save changes
         BRA C3C697      ; Skip 5 lines

; Fork: Clear item slot, leave submenu
C3C68B:  JSR C3CF26      ; Define Y
         LDA #$FF        ; Empty item
         STA $1869,Y     ; Put in slot
         TDC             ; Quantity: 0
         STA $1969,Y     ; Assign to slot
C3C697:  JSR C33369      ; Cap GP
         LDY #C3D327     ; Text pointer
         JSR C30326      ; Draw "Bye!"
         LDA #$2B        ; C3/C6A9
         STA $26         ; Next: Exit
         LDA #$20        ; Frames: 32
         STA $20         ; Set delay
         RTS

; 2B: Return to Sell menu after delay
C3C6A9:  LDA $20         ; Delay expired?
         BNE C3C6B6      ; Exit if not
         LDX $00         ; Clear X
         STX $39         ; BG2 X-Pos: 0
         STX $3B         ; BG2 Y-Pos: 0
         JSR C3C726      ; Exit submenu
C3C6B6:  RTS

; Return to main shop menu
C3C6B7:  LDA #$C0        ; Scrollbar: Off
         TRB $46         ; Set anim index
         STZ $47         ; Actors: Off
         JSR C3C7DD      ; Load navig data
         JSR C3C7E6      ; Relocate cursor
         JSR C30F68      ; Set to upload BG1
         JSR C3C8AB      ; Clear BG1 maps
         JSR C313D3      ; Refresh screen
         JSR C30FA4      ; Queue BG3 upload
         JSR C3C8B7      ; Clean up BG3
         LDY #C3D27E     ; Text pointer
         JSR C30326      ; Draw options
         LDY #C3D2C2     ; Text pointer
         JSR C30326      ; Draw greeting
         LDY $00         ; Clear Y
         STY $39         ; Reset BG2 X-Pos
         STY $3B         ; Reset BG2 Y-Pos
         LDA #$25        ; C3/C3F2
         STA $26         ; Next: Shop menu
         RTS

; Handle selected option in shop menu
C3C6E9:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         ASL A           ; Double it
         TAX             ; Index it
         JMP (C3C6F1,X)  ; Handle option

; Jump table
C3C6F1:  dw C3C6FA       ; BUY
         dw C3C71E       ; SELL
         dw C3C6F7       ; EXIT

; Exit shop
C3C6F7:  JMP C3C40A      ; Queue menu exit

; Initialize Buy menu
C3C6FA:  JSR C3C7F7      ; Load navig data
         JSR C3C800      ; Relocate cursor
         LDA #$08        ; Arm waving: On
         TRB $47         ; Never off...
         JSR C3CFF5      ; Create actors
         JSR C3D196      ; Create signs
C3C70A:  LDY #$0100      ; X: 256
         STY $39         ; Set BG2 X-Pos
         LDY $00         ; Y: 0
         STY $3B         ; Set BG2 Y-Pos
         JSR C3C8E3      ; Draw all text
         JSR C3CC58      ; Build sign list
         LDA #$26        ; C3/C414
         STA $26         ; Next: Buy list
         RTS

; Initialize Sell menu
C3C71E:  JSR C30FA4      ; Queue BG3 upload
         JSR C3CB37      ; Cursor/list/bar
         BRA C3C729      ; Skip a line

; Return to Sell menu
C3C726:  JSR C3CB59      ; Draw list; bar
C3C729:  JSR C3C8B7      ; Draw title, GP
         LDY #C3D27E     ; Text pointer
         JSR C30326      ; Draw options
         LDY #C3D300     ; Text pointer
         JSR C30326      ; Draw question
         LDA #$29        ; C3/C56D
         STA $26         ; Next: Sell list
         RTS

; Invoke buy order menu if justified
C3C73D:  JSR C3CF1D      ; Selected item
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Tool?
         BNE C3C761      ; Branch if not
         JSR C3CBED      ; Define $64
         LDA $64         ; Owning none?
         BEQ C3C761      ; Test GP if so
         JSR C30F2B      ; Play buzzer
         LDY #C3D363     ; Text pointer
         JSR C30326      ; Draw excuse
         JMP C3C7D4      ; Set to exit

; Fork: Check if enough money
C3C761:  LDA $1862       ; GP > 65535?
         BNE C3C795      ; Ample if so
         TDC             ; ...
         LDA $4B         ; Selected slot
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA $7E9F09,X   ; Item's price
         CMP $1860       ; Got as much?
         SEP #$20        ; 8-bit A
         BEQ C3C795      ; Ample if so
         BCC C3C795      ; Or if more
         JSR C30F2B      ; Play buzzer
         LDY #C3D33D     ; Text pointer
         JSR C30326      ; Draw excuse
         JMP C3C7D4      ; Set to exit

; Sub: Define buy quantity limit
C3C786:  LDA $64         ; Qty in stock
         CLC             ; Prepare ADC
         ADC $65         ; Add qty worn
         STA $69         ; Set total owned
         LDA #$63        ; Quantity: 99
         SEC             ; Prepare SBC
         SBC $69         ; Sub total owned
         STA $6A         ; Set buy limit
         RTS

; Fork: Check if owning 99
C3C795:  LDA $69         ; Qty owned/worn
         CMP #$63        ; Under 99?
         BCC C3C7A7      ; Okay if so
         JSR C30F2B      ; Play buzzer
         LDY #C3D351     ; Text pointer
         JSR C30326      ; Draw "Too many!"
         JMP C3C7D4      ; Set to exit

; Fork: Can buy item
C3C7A7:  JSR C30F1D      ; Sound: Click
         LDX #$0008      ; X: 8
         STX $55         ; Set cursor's
         LDX #$0034      ; Y: 52
         STX $57         ; Set cursor's
         LDA #$27        ; C3/C45C
         STA $26         ; Next: Order menu
         JSR C3CA02      ; Draw blue text
         JSR C3CA17      ; Draw item info
         LDY #C3D2EE     ; Text pointer
         JSR C30326      ; Draw "How many?"

; Fork: Switch screen
C3C7C4:  LDY #$0100      ; Y: 256
         STY $3B         ; Set BG2 Y-Pos
         LDY $00         ; X: 0
         STY $39         ; Set BG2 X-Pos
         JSR C3B0D9      ; Clear desc GFX
         JSR C3B037      ; Build desc map
         RTS

; Set to return to Buy menu after delay
C3C7D4:  LDA #$28        ; C3/C565
         STA $26         ; Next: Exit
         LDA #$20        ; Frames: 32
         STA $20         ; Set delay
         RTS

; Load navigation data for main shop menu
C3C7DD:  LDY #C3C7EC     ; C3/C7EC
         JMP C30681      ; Load navig data

; Handle D-Pad for main shop menu
C3C7E3:  JSR C307B0      ; Handle D-Pad
C3C7E6:  LDY #C3C7F1     ; C3/C7F1
         JMP C306C3      ; Relocate cursor

; Navigation data for main shop menu
C3C7EC:  db $01          ; Wraps horizontally
         db $00          ; Initial column
         db $00          ; Initial row
         db $03          ; 3 columns
         db $01          ; 1 row

; Cursor positions for main shop menu
C3C7F1:  dw $3408        ; BUY
         dw $3428        ; SELL				=== SNES: Shifted rightward (below too)
         dw $3448        ; EXIT

; Load navigation data for Buy menu
C3C7F7:  LDY #C3C806     ; C3/C806
         JMP C30681      ; Load navig data

; Handle D-Pad for Buy menu
C3C7FD:  JSR C307B0      ; Handle D-Pad
C3C800:  LDY #C3C80B     ; C3/C80B
         JMP C306C3      ; Relocate cursor

; Navigation data for Buy menu
C3C806:  db $80          ; Wraps vertically
         db $00          ; Initial column
         db $00          ; Initial row
         db $01          ; 1 column
         db $08          ; 8 rows

; Cursor positions for Buy menu
C3C80B:  dw $3408        ; Item 1			=== SNES: All shifted left (longer names)
         dw $4008        ; Item 2
         dw $4C08        ; Item 3
         dw $5808        ; Item 4
         dw $6408        ; Item 5
         dw $7008        ; Item 6
         dw $7C08        ; Item 7
         dw $8808        ; Item 8

; Draw main shop menu and submenu windows, set to update description
C3C81B:  JSR C371BC      ; Clear BG2 map A
         JSR C371C1      ; Clear BG2 map B
         JSR C371C6      ; Clear BG2 map C
         LDY #C3CB72     ; C3/CB72
         JSR C303C4      ; Draw title box A
         LDY #C3CB76     ; C3/CB76
         JSR C303C4      ; Draw chat box A
         LDY #C3CB7A     ; C3/CB7A
         JSR C303C4      ; Draw option box
         LDY #C3CB7E     ; C3/CB7E
         JSR C303C4      ; Draw GP box
         LDY #C3CB82     ; C3/CB82
         JSR C303C4      ; Draw item box A
         LDY #C3CB86     ; C3/CB86
         JSR C303C4      ; Draw title box B
         LDY #C3CB8A     ; C3/CB8A
         JSR C303C4      ; Draw chat box B
         LDY #C3CB96     ; C3/CB96
         JSR C303C4      ; Draw actor box A
         LDY #C3CB8E     ; C3/CB8E
         JSR C303C4      ; Draw item box B
         LDY #C3CB92     ; C3/CB92			%%%
         JSR C303C4      ; Draw amounts box
         LDY #C3CB9A     ; C3/CB9A
         JSR C303C4      ; Draw title box C
         LDY #C3CBAE     ; C3/CBAE
         JSR C303C4      ; Draw amounts box
         LDY #C3CBA6     ; C3/CBA6
         JSR C303C4      ; Draw desc box
         LDY #C3CB9E     ; C3/CB9E
         JSR C303C4      ; Draw chat box C
         LDY #C3CBAA     ; C3/CBAA
         JSR C303C4      ; Draw actor box B
         LDY #C3CBA2     ; C3/CBA2
         JSR C303C4      ; Draw item box C
         JSR C30EBD      ; Upload BG2 A+B
         JSR C30ECB      ; Upload BG2 C+D
         JSR C3C8AB      ; Clear BG1 maps
         JSR C30E93      ; Upload BG1 A+B
         JSR C30EAF      ; Upload BG1 C+D...
         JSR C3C8B7      ; Draw title, GP
         LDY #C3D27E     ; Text pointer
         JSR C30326      ; Draw options
         LDY #C3D2C2     ; Text pointer
         JSR C30326      ; Draw greeting
         JSR C31BFF      ; Queue desc anim
         JSR C30ED9      ; Upload BG3 A+B
         JMP C30EE7      ; Upload BG3 C+D

; Clear BG1 tilemaps (for shop)
C3C8AB:  JSR C371A9      ; Clear BG1 map A
         JSR C371AD      ; Clear BG1 map B
         JSR C371B2      ; Clear BG1 map C
         JMP C371B7      ; Clear BG1 map D

; Draw shop title and party's gold, clear rest of BG3
C3C8B7:  JSR C371D0      ; Clear BG3 map A
         JSR C371D5      ; Clear BG3 map B
         JSR C371DA      ; Clear BG3 map C
         JSR C3CF2E      ; Draw title
         JSR C3D252      ; ...
         LDY #C3D28B     ; Text pointer
         JSR C30326      ; Draw "GP"
         JSR C3D24D      ; Color: User's
         LDY $1860       ; Gold LBs
         STY $F1         ; Memorize it
         LDA $1862       ; Gold HB
         STA $F3         ; Memorize it
         JSR C30605      ; Turn into text
         LDX #$7A33      ; Text position
         JSR C3052F      ; Draw GP total
         RTS

; Draw all text for Buy menu
C3C8E3:  JSR C3C8B7      ; Draw title, GP
         LDY #C3D2D8     ; Text pointer
         JSR C30326      ; Draw "Help..."
         JSR C3D23C      ; Draw Owned, Eqpd
         LDY $00         ; Clear Y
         STY $F1         ; Menu slot: 1
         STZ $E6         ; List size: 0
C3C8F5:  REP #$20        ; 16-bit A
         LDA $F1         ; Menu slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C3C959,X  ; Tilemap ptr
         STA $7E9E89     ; Set position
         LDA $F1         ; Menu slot
         CLC             ; ...
         ADC $67         ; Add shop index
         INC A           ; Skip flags
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA $C47AC0,X   ; Shop item
         LDX $F1         ; Menu slot
         STA $7E9D89,X   ; Assign item
         CMP #$FF        ; Nothing?
         BEQ C3C941      ; Branch if so
         JSR C3CFC3      ; Load name
         JSR C387B9      ; Draw name
         LDX $F1         ; Menu slot
         LDA $7E9D89,X   ; Item in slot
         JSR C38AA2      ; Compute index
         JSR C3C969      ; Define price
         JSR C305B1      ; Turn into text
         REP #$20        ; 16-bit A
         LDA $7E9E89     ; Tilemap ptr
         CLC             ; Prepare ADC
         ADC #$0056      ; Row +1, col +11		=== SNES: +40h as no diacritics; col +13
         TAX             ; Put sum in X
         SEP #$20        ; 8-bit A
         JSR C3051D      ; Draw price
         INC $E6         ; List size +1
C3C941:  LDY $F1         ; Menu slot
         INY             ; Menu slot +1
         STY $F1         ; Save changes
         CPY #$0008      ; Done 8 items?
         BNE C3C8F5      ; Loop if not
         LDA $E6         ; List size
         STA $54         ; Set cursor limit
         JSR C3CBB2      ; Get qties owned
         JSR C3CBDF      ; Draw qty owned
         JSR C3CC03      ; Draw qty worn
         RTS

; Tilemap pointers for Buy menu				=== SNES: +40h as no diacritics; shifted leftward
C3C959:  dw $79CF        ; Item 1
         dw $7A4F        ; Item 2
         dw $7ACF        ; Item 3
         dw $7B4F        ; Item 4
         dw $7BCF        ; Item 5
         dw $7C4F        ; Item 6
         dw $7CCF        ; Item 7
         dw $7D4F        ; Item 8

; Define cost to buy item
C3C969:  REP #$20        ; 16-bit A
         LDA $2134       ; Item index
         CLC             ; Prepare ADC
         ADC #$001C      ; Point to price
         TAX             ; Index sum
         LDA $D85000,X   ; Base price
         JSR C3C989      ; Apply multiplier
         STA $F3         ; Memorize result
         LDA $F1         ; Menu slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $F3         ; Modified price
         STA $7E9F09,X   ; Set item price
         SEP #$20        ; 8-bit A
         RTS

; Apply price multiplier for Buy menu
C3C989:  PHA             ; Save price
         LDX $67         ; Shop index
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $C47AC0,X   ; Shop flags
         AND #$38        ; Get modifier
         REP #$20        ; 16-bit A
         LSR A           ; Put in b2-b4
         LSR A           ; Put in b1-b3
         TAX             ; Index it
         PLA             ; Base price
         JMP (C3C99E,X)  ; Apply modifier

; Jump table for price multipliers
C3C99E:  dw C3C9B2       ; 100%
         dw C3C9AC       ; 150%
         dw C3C9B3       ; 200%
         dw C3C9B5       ; 50%
         dw C3C9B7       ; 50% if female leads, 150% otherwise
         dw C3C9D3       ; 50% if male leads, 150% otherwise
         dw C3C9EF       ; 50% if Edgar leads

; Increase price by 50% (unused)
C3C9AC:  STA $E7         ; Save price
         LSR A           ; Halve it
         CLC             ; Prepare ADC
         ADC $E7         ; Add base price
C3C9B2:  RTS

; Double price (unused)
C3C9B3:  ASL A           ; Double price
         RTS

; Halve price
C3C9B5:  LSR A           ; Halve price
         RTS

; Halve price if female leads, raise by 50% otherwise (unused)
C3C9B7:  PHA             ; Save price
         SEP #$20        ; 8-bit A
         LDA $0202       ; Leader sprite
         CMP #$06        ; Celes?
         BEQ C3C9CE      ; Halve if so
         CMP #$08        ; Relm?
         BEQ C3C9CE      ; Halve if so
         CMP #$00        ; Terra?
         BEQ C3C9CE      ; Halve if so
         REP #$20        ; 16-bit A
         PLA             ; Base price
         BRA C3C9AC      ; Add 50%
C3C9CE:  REP #$20        ; 16-bit A
         PLA             ; Base price
         BRA C3C9B5      ; Halve it

; Halve price if male leads, raise by 50% otherwise (unused)
C3C9D3:  PHA             ; Save price
         SEP #$20        ; 8-bit A
         LDA $0202       ; Leader sprite
         CMP #$06        ; Celes?
         BEQ C3C9EA      ; +50% if so
         CMP #$08        ; Relm?
         BEQ C3C9EA      ; +50% if so
         CMP #$00        ; Terra?
         BEQ C3C9EA      ; +50% if so
         REP #$20        ; 16-bit A
         PLA             ; Base price
         BRA C3C9B5      ; Halve it
C3C9EA:  REP #$20        ; 16-bit A
         PLA             ; Base price
         BRA C3C9AC      ; Add 50%

; Halve price if Edgar leads
C3C9EF:  PHA             ; Save price
         SEP #$20        ; 8-bit A
         LDA $0202       ; Leader sprite
         CMP #$04        ; Edgar?
         BEQ C3C9FD      ; Halve if so
         REP #$20        ; 16-bit A
         PLA             ; Base price
         RTS             ; Exit
C3C9FD:  REP #$20        ; 16-bit A
         PLA             ; Base price
         BRA C3C9B5      ; Halve it

; Draw blue text for shop order menu, position item name
C3CA02:  JSR C30FA4      ; Queue BG3 upload
         JSR C3C8B7      ; Clean up BG3
         JSR C3D23C      ; Draw Owned, Eqpd
         REP #$20        ; 16-bit A
         LDA #$79CF      ; Tilemap ptr			=== SNES: +40h as no diacritics
         STA $7E9E89     ; Set item position
         SEP #$20        ; 8-bit A
         RTS

; Draw item specs for buy order menu, reset buy quantity
C3CA17:  JSR C3CA49      ; Draw power info
         JSR C3CBDF      ; Draw qty owned
         JSR C3CC03      ; Draw qty worn
         JSR C3CF1D      ; Selected item
         JSR C3CFC3      ; Load name
         JSR C387B9      ; Draw name
         LDA #$01        ; Quantity: 1
         STA $28         ; Set order size
         JMP C3CB05      ; Draw size, value

; Draw item specs for sell order menu, reset sell quantity
C3CA30:  JSR C3CBF8      ; Draw qty owned
         JSR C3CEC1      ; Draw qty worn
         JSR C3CA4F      ; Draw power info
         JSR C3CF26      ; Selected item
         JSR C3CFC3      ; Load name
         JSR C387B9      ; Draw name
         LDA #$01        ; Quantity: 1
         STA $28         ; Set order size
         JMP C3CB0E      ; Draw size, value

; Draw power-related text for Buy menu
C3CA49:  JSR C3CF1D      ; Selected item
         JMP C3CA55      ; Draw power info

; Draw power-related text for Sell menu
C3CA4F:  JSR C3CF26      ; Selected item
         JMP C3CA55      ; ...

; Draw power-related text for Buy or Sell menu
C3CA55:  JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Tool?
         BEQ C3CAA9      ; Exit if so
         CMP #$06        ; Consumable?
         BEQ C3CAA9      ; Exit if so
         CMP #$01        ; Weapon?
         BEQ C3CA8D      ; Branch if so
         JSR C3D24D      ; Color: User's
         LDA $D85014,X   ; Defense
         JSR C30563      ; Turn into text
         LDX #$7BA9      ; Text position
         JSR C30543      ; Draw 3 digits
         JSR C3D252      ; Color: Blue
         LDY #C3D2B7     ; Text pointer
         JSR C30326      ; Draw "Defense"
         LDY #C3D2BE     ; Text pointer
         JSR C302F9      ; Draw ".."			=== SNES: "…"
         JMP C3D24D      ; Color: User's

; Fork: Handle weapon
C3CA8D:  JSR C3D24D      ; Color: User's
         LDA $D85014,X   ; Bat.Pwr
         JSR C30563      ; Turn into text
         LDX #$7BA9      ; Text position
         JSR C30543      ; Draw 3 digits
         JSR C3D252      ; Color: Blue
         LDY #C3D2AB     ; Text pointer
         JSR C30326      ; Draw "Bat Pwr"
         JSR C3D24D      ; Color: User's


C3CAA9:  RTS             ; For Owned, etc.

; Compute buy order value
C3CAAA:  TDC             ; Clear A
         LDA $4B         ; Item slot
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA $7E9F09,X   ; Price asked
         STA $F1         ; Memorize it
         SEP #$20        ; 8-bit A
         JMP C3CAD8      ; Price x size

; Compute sell order value
C3CABC:  JSR C3CF26      ; Selected item
         JSR C38AA2      ; Compute index
         REP #$20        ; 16-bit A
         LDA $2134       ; Load it
         CLC             ; Prepare ADC
         ADC #$001C      ; Point to price
         TAX             ; Index sum
         LDA $D85000,X   ; Base price
         LSR A           ; Halve it
         STA $F1         ; Memorize it
         SEP #$20        ; 8-bit A
         JMP C3CAD8      ; ...

; Compute buy or sell order value
C3CAD8:  LDA $F1         ; Item value LB
         STA $4202       ; Set multiplicand
         LDA $28         ; Item quantity
         STA $4203       ; Set multiplier
         STZ $EF         ; Product's B3: 0
         NOP
         NOP
         LDX $4216       ; Product
         STX $ED         ; Memorize it
         LDA $F2         ; Item value HB
         STA $4202       ; Set multiplicand
         LDA $28         ; Item quantity
         STA $4203       ; Set multiplier
         REP #$21        ; 16-bit A; C-
         LDA $EE         ; Old product HBs
         ADC $4216       ; Add new product
         STA $F2         ; Set total HBs
         SEP #$20        ; 8-bit A
         LDA $ED         ; Old product LB
         STA $F1         ; Set total LB
         RTS

; Draw buy order size and value
C3CB05:  JSR C3CB17      ; Draw order size
         JSR C3CAAA      ; Get order value
         JMP C3CB2E      ; Draw order value

; Draw sell order size and value
C3CB0E:  JSR C3CB17      ; Draw order size
         JSR C3CABC      ; Get order value
         JMP C3CB2E      ; Draw order value

; Draw traded item's quantity and "GP" below
C3CB17:  JSR C3D252      ; Color: Blue
         LDY #C3D290     ; Text pointer
         JSR C30326      ; Draw "GP"
         JSR C3D24D      ; Color: User's
         LDA $28         ; Order size
         JSR C30563      ; Turn into text
         LDX #$7A2B      ; Text position
         JMP C30539      ; Draw 2 digits

; Draw order value (held in $F1-$F4)
C3CB2E:  JSR C30605      ; Turn into text
         LDX #$7AA1      ; Text position
         JMP C3052F      ; Draw 7 digits

; Initialize cursor data and draw inventory for Sell menu
C3CB37:  LDA #$01        ; 64x32 at $0000
         STA $2107       ; Set BG1 map loc
         LDA #$76        ; Top row: 119th		=== SNES: 246
         STA $5C         ; Set scroll limit
         LDA #$0A        ; Onscreen rows: 10
         STA $5A         ; Set rows per page
         LDA #$02        ; Onscreen cols: 2		=== SNES: 1
         STA $5B         ; Set cols per page
         JSR C384A3      ; Load navig data
         LDY $4D         ; Cursor position
         STY $4F         ; Set as list loc
         LDA $4A         ; Scroll position
         CLC             ; Prepare ADC
         ADC $50         ; Add list V-Slot
         STA $50         ; Set list V-Slot
         JSR C384AC      ; Relocate cursor
C3CB59:  JSR C385BC      ; Draw inventory
         JSR C309A4      ; Create scrollbar
         REP #$20        ; 16-bit A
         LDA #$00EA      ; V-Speed: 0.914 px		=== SNES: 0.44
         STA $7E354A,X   ; Set scrollbar's
         LDA #$0058      ; Y: 88
         STA $7E34CA,X   ; Set scrollbar's
         SEP #$20        ; 8-bit A
         RTS

; Window layout for Sell menu and main shop menu
C3CB72:  dw $588B,$0207  ; 09x04 at $588B (Title)
C3CB76:  dw $589D,$0213  ; 21x04 at $589D (Dialogue)
C3CB7A:  dw $598B,$020C  ; 14x04 at $598B (Options)	=== SNES: Longer on right side
C3CB7E:  dw $59A7,$020E  ; 16x04 at $59A7 (GP)		=== SNES: Shorter on left side
C3CB82:  dw $5A8B,$101C  ; 30x18 at $5A8B (Items)

; Window layout for Buy menu
C3CB86:  dw $608B,$0207  ; 09x04 at $608B (Title)
C3CB8A:  dw $609D,$0213  ; 21x04 at $609D (Dialogue)
C3CB8E:  dw $618B,$0C11  ; 19x14 at $618B (Items)	=== SNES: No amount box, so covers entire area
C3CB92:  dw $61B1,$0C09  ; 11x14 at $61B1 (Amounts)	%%%
C3CB96:  dw $650B,$061C  ; 30x08 at $650B (Actors)

; Window layout for shop order menus
C3CB9A:  dw $688B,$0207  ; 09x04 at $688B (Title)
C3CB9E:  dw $689D,$0213  ; 21x04 at $689D (Dialogue)
C3CBA2:  dw $698B,$0711  ; 19x09 at $698B (Item)
C3CBA6:  dw $6BCB,$031C  ; 30x05 at $6BCB (Description)
C3CBAA:  dw $6D0B,$061C  ; 30x08 at $6D0B (Actors)
C3CBAE:  dw $69B1,$0709  ; 11x09 at $69B1 (Amounts)

; Compile quantity owned of each item in Buy menu
C3CBB2:  LDX #$9DC9      ; 7E/9DC9
         STX $2181       ; Set WRAM LBs
         TDC             ; Clear A
         TAX             ; Menu slot: 1
C3CBBA:  PHX             ; ...
         LDY $00         ; Stock slot: 1
         LDA $7E9D89,X   ; Shop item
C3CBC1:  CMP $1869,Y     ; In stock slot?
         BEQ C3CBD1      ; Branch if so
         INY             ; Stock slot +1
         CPY #$0100      ; Done all 256?
         BNE C3CBC1      ; Loop if not
         STZ $2180       ; Quantity: 0
         BRA C3CBD7      ; Skip 2 lines
C3CBD1:  LDA $1969,Y     ; Quantity owned
         STA $2180       ; Set shop item's
C3CBD7:  PLX             ; ...
         INX             ; Menu slot +1
         CPX #$0008      ; Done 8 items?
         BNE C3CBBA      ; Loop if not
         RTS

; Load and draw quantity owned of item in Buy menu
C3CBDF:  JSR C3CBED      ; Define $64
C3CBE2:  LDA $64         ; Quantity owned
         JSR C30563      ; Turn into text
         LDX #$7B3F      ; Text position
         JMP C30539      ; Draw 2 digits

; Get quantity owned of item in Buy menu
C3CBED:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9DC9,X   ; Quantity owned
         STA $64         ; Set as current
         RTS

; Load and draw quantity owned of item in Sell menu
C3CBF8:  TDC             ; Clear A
         LDA $4B         ; List slot
         TAY             ; Index it
         LDA $1969,Y     ; Item quantity
         STA $64         ; Memorize it
         BRA C3CBE2      ; Draw quantity

; Count and draw quantity worn of item in Buy menu
C3CC03:  JSR C3CF1D      ; Item in slot
         JMP C3CEC4      ; Draw quantity

; Get sign found by actor for shop item
C3CC09:  JSR C3CC24      ; Actor can use?
         BCC C3CC22      ; No sign if not
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         REP #$20        ; ...
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         SEP #$20        ; ...
         CLC             ; ...
         ADC $E0         ; Add char slot
         TAX             ; Index sum
         LDA $7EAA8D,X   ; Sign
         RTS             ; Exit
C3CC22:  TDC             ; Sign: None
         RTS

; Check whether actor can equip shop item
C3CC24:  PHB             ; Save DB
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         TDC             ; Clear A
         STA $11D8       ; No Merit Award
         TDC             ; ...
         LDA $E0         ; Char list slot
         TAX             ; Index it
         LDA $7E9E09,X   ; Actor in slot
         JSR C3A437      ; Define compat
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Item in slot
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         AND $E7         ; Actor can use?
         SEP #$20        ; 8-bit A
         BEQ C3CC55      ; Branch if not
         PLB             ; Restore DB
         SEC             ; Mark success
         RTS             ; Exit
C3CC55:  PLB             ; Restore DB
         CLC             ; Mark failure
         RTS

; Build sign list for each item in Buy menu
C3CC58:  JSR C3CEAA      ; Clear sign list
         LDY #$AA8D      ; 7E/AA8D
         STY $F3         ; Save WRAM adr
         TDC             ; ...
         TAX             ; Item slot: 1
C3CC62:  LDY $F3         ; WRAM address
         STY $2181       ; Set WRAM LBs
         PHX             ; Save item slot
         LDA $7E9D89,X   ; Item in slot
         STA $9F         ; Memorize it
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85014,X   ; Item's power
         STA $9E         ; Memorize it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$01        ; Weapon?
         BEQ C3CD00      ; Branch if so
         CMP #$02        ; Armor?
         BEQ C3CCA0      ; Branch if so
         CMP #$03        ; Shield?
         BEQ C3CC9A      ; Branch if so
         CMP #$04        ; Helmet?
         BEQ C3CC9D      ; Branch if so
         CMP #$05        ; Relic?
         BEQ C3CC97      ; Branch if so
         JMP C3CE65      ; Handle non-gear
C3CC97:  JMP C3CE73      ; Handle relic
C3CC9A:  JMP C3CD90      ; Handle shield
C3CC9D:  JMP C3CE18      ; Handle helmet

; Fork: Build sign list for armor
C3CCA0:  TDC             ; Clear A
         TAX             ; 1st: Terra
C3CCA2:  PHX             ; Save actor index
         REP #$20        ; 16-bit A
         LDA $1EDC       ; Shown actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C3CCE2      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         TDC             ; ...
         LDA $0022,Y     ; Actor's armor
         CMP $9F         ; In shop slot?
         BEQ C3CCD9      ; Use "E" if so
         CMP #$FF        ; None?
         BEQ C3CCD1      ; Use "^" if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85014,X   ; Item's defense
         CMP $9E         ; Matches shop's?
         BEQ C3CCDD      ; Use "=" if so
         BCS C3CCD5      ; Use "v" if above
C3CCD1:  LDA #$02        ; Sign: "^"
         BRA C3CCDF      ; Add to list

; Subfork: Use "v" sign for armor
C3CCD5:  LDA #$03        ; Sign: "v"
         BRA C3CCDF      ; Add to list

; Subfork: Use "E" sign for armor
C3CCD9:  LDA #$01        ; Sign: "E"
         BRA C3CCDF      ; Skip a line

; Subfork: Use "=" sign for armor
C3CCDD:  LDA #$04        ; Sign: "="
C3CCDF:  STA $2180       ; Add to list
C3CCE2:  PLX             ; Actor index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 chars?
         BNE C3CCA2      ; Loop if not

; Fork: Handle next item
C3CCEA:  REP #$21        ; 16-bit A; C-
         LDA $F3         ; WRAM address
         ADC #$0010      ; Reach next item
         STA $F3         ; Save changes
         SEP #$20        ; 8-bit A
         PLX             ; Item slot
         INX             ; Item slot +1
         CPX #$0008      ; Done 8 items?
         BNE C3CCFD      ; Loop if not
         RTS             ; Exit
C3CCFD:  JMP C3CC62      ; Do next item

; Fork: Build sign list for weapon
C3CD00:  TDC             ; Clear A
         TAX             ; 1st: Terra
C3CD02:  PHX             ; Save actor index
         REP #$20        ; 16-bit A
         LDA $1EDC       ; Shown actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C3CD82      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         SEP #$20        ; 8-bit A

; Subfork: Check if holding shop item
C3CD15:  LDA $001F,Y     ; R-Hand item
         CMP $9F         ; In shop slot?
         BEQ C3CD79      ; Use "E" if so
         LDA $0020,Y     ; L-Hand item
         CMP $9F         ; In shop slot?
         BEQ C3CD79      ; Use "E" if so

; Subfork: Check if weapon in R-Hand
C3CD23:  TDC             ; ...
         LDA $001F,Y     ; R-Hand item
         CMP #$FF        ; None?
         BEQ C3CD3B      ; Branch if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$01        ; Weapon?
         BEQ C3CD59      ; Branch if so

; Subfork: No weapon in R-Hand, check L-Hand
C3CD3B:  TDC             ; ...
         LDA $0020,Y     ; L-Hand item
         CMP #$FF        ; None?
         BEQ C3CD71      ; Use "^" if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$01        ; Weapon?
         BNE C3CD59      ; Branch if not
         TDC             ; ...
         LDA $0020,Y     ; L-Hand item
         BRA C3CD5D      ; Compare power

; Subfork: Compare weapons' power
C3CD59:  TDC             ; ...
         LDA $001F,Y     ; R-Hand item
C3CD5D:  CMP #$FF        ; None?
         BEQ C3CD71      ; Use "^" if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85014,X   ; Item's Bat.Pwr
         CMP $9E         ; Matches shop's?
         BEQ C3CD7D      ; Use "=" if so
         BCS C3CD75      ; Use "v" if above
C3CD71:  LDA #$02        ; Sign: "^"
         BRA C3CD7F      ; Add to list

; Subfork: Use "v" sign for weapon
C3CD75:  LDA #$03        ; Sign: "v"
         BRA C3CD7F      ; Add to list

; Subfork: Use "E" sign for weapon
C3CD79:  LDA #$01        ; Sign: "E"
         BRA C3CD7F      ; Skip a line

; Subfork: Use "=" sign for weapon
C3CD7D:  LDA #$04        ; Sign: "="
C3CD7F:  STA $2180       ; Add to list
C3CD82:  PLX             ; Actor index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 chars?
         BNE C3CD8D      ; Loop if not
         JMP C3CCEA      ; Do next item
C3CD8D:  JMP C3CD02      ; Do next actor

; Fork: Build sign list for shield
C3CD90:  TDC             ; Clear A
         TAX             ; 1st: Terra
C3CD92:  PHX             ; Save actor index
         REP #$20        ; 16-bit A
         LDA $1EDC       ; Shown actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C3CE0A      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         SEP #$20        ; 8-bit A

; Subfork: Check if holding shop item
C3CDA5:  LDA $001F,Y     ; R-Hand item
         CMP $9F         ; In shop slot?
         BEQ C3CE01      ; Use "E" if so
         LDA $0020,Y     ; L-Hand item
         CMP $9F         ; In shop slot?
         BEQ C3CE01      ; Use "E" if so

; Subfork: Check if holding a shield
C3CDB3:  TDC             ; ...
         LDA $0020,Y     ; L-Hand item...
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$03        ; Shield?
         BEQ C3CDE1      ; Branch if so
         TDC             ; ...
         LDA $001F,Y     ; R-Hand item
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85000,X   ; Properties
         AND #$07        ; Get class
         CMP #$03        ; Shield?
         BNE C3CDF9      ; Use "^" if not
         TDC             ; ...
         LDA $001F,Y     ; R-Hand item
         BRA C3CDE5      ; Compare defense

; Subfork: Compare shields' defense
C3CDE1:  TDC             ; ...
         LDA $0020,Y     ; L-Hand item...
C3CDE5:  CMP #$FF        ; None?...
         BEQ C3CDF9      ; Use "^" if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85014,X   ; Item's defense
         CMP $9E         ; Matches shop's?
         BEQ C3CE05      ; Use "=" if so
         BCS C3CDFD      ; Use "v" if above
C3CDF9:  LDA #$02        ; Sign: "^"
         BRA C3CE07      ; Add to list

; Subfork: Use "v" sign for shield
C3CDFD:  LDA #$03        ; Sign: "v"
         BRA C3CE07      ; Add to list

; Subfork: Use "E" sign for shield
C3CE01:  LDA #$01        ; Sign: "E"
         BRA C3CE07      ; Skip a line

; Subfork: Use "=" sign for shield
C3CE05:  LDA #$04        ; Sign: "="
C3CE07:  STA $2180       ; Add to list
C3CE0A:  PLX             ; Actor index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 chars?
         BNE C3CE15      ; Loop if not
         JMP C3CCEA      ; Do next item
C3CE15:  JMP C3CD92      ; Do next actor

; Fork: Build sign list for helmet
C3CE18:  TDC             ; Clear A
         TAX             ; 1st: Terra
C3CE1A:  PHX             ; Save char index
         REP #$20        ; 16-bit A
         LDA $1EDC       ; Shown actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C3CE5A      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         TDC             ; ...
         LDA $0021,Y     ; Actor's helmet
         CMP $9F         ; In shop slot?
         BEQ C3CE51      ; Use "E" if so
         CMP #$FF        ; None?
         BEQ C3CE49      ; Use "^" if so
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         LDA $D85014,X   ; Item's defense
         CMP $9E         ; Matches shop's?
         BEQ C3CE55      ; Use "=" if so
         BCS C3CE4D      ; Use "v" if above
C3CE49:  LDA #$02        ; Sign: "^"
         BRA C3CE57      ; Add to list

; Subfork: Use "v" sign for helmet
C3CE4D:  LDA #$03        ; Sign: "v"
         BRA C3CE57      ; Add to list

; Subfork: Use "E" sign for helmet
C3CE51:  LDA #$01        ; Sign: "E"
         BRA C3CE57      ; Skip a line

; Subfork: Use "=" sign for helmet
C3CE55:  LDA #$04        ; Sign: "="
C3CE57:  STA $2180       ; Add to list
C3CE5A:  PLX             ; Actor index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 chars?
         BNE C3CE1A      ; Loop if not
         JMP C3CCEA      ; Do next item

; Fork: Clear sign list for consumable or tool
C3CE65:  TDC             ; Sign: None
         TAX             ; Actors done: 0
C3CE67:  STA $2180       ; Add sign to list
         INX             ; Actors done +1
         CPX #$0010      ; Done all 16?
         BNE C3CE67      ; Loop if not
         JMP C3CCEA      ; Do next item

; Fork: Build sign list for relic
C3CE73:  TDC             ; Clear A
         TAX             ; 1st: Terra
C3CE75:  PHX             ; Save char index
         REP #$20        ; 16-bit A
         LDA $1EDC       ; Shown actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C3CE9F      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         TDC             ; ...
         LDA $0023,Y     ; Actor relic 1
         CMP $9F         ; In shop slot?
         BEQ C3CE9A      ; Use "E" if so
         LDA $0024,Y     ; Actor relic 2
         CMP $9F         ; In shop slot?
         BEQ C3CE9A      ; Use "E" if so
         TDC             ; Sign: None
         BRA C3CE9C      ; Skip a line
C3CE9A:  LDA #$01        ; Sign: "E"
C3CE9C:  STA $2180       ; Add to list
C3CE9F:  PLX             ; Actor index
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0020      ; Done 16 chars?
         BNE C3CE75      ; Loop if not
         JMP C3CCEA      ; Do next item

; Clear sign list for every item in Buy menu (16 actors per item)
C3CEAA:  PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         TAX             ; Index: 0
         REP #$20        ; 16-bit A
C3CEB3:  STZ $AA8D,X     ; Clear 2 signs
         INX             ; Index +1
         INX             ; Index +1
         CPX #$0080      ; Done 8 items?
         BNE C3CEB3      ; Loop if not
         SEP #$20        ; 8-bit A
         PLB             ; Restore DB
         RTS

; Count and draw quantity worn of item in Sell menu
C3CEC1:  JSR C3CF26      ; Selected item
C3CEC4:  STA $E0         ; Memorize it
         STZ $65         ; Quantity worn: 0
         LDX #$161F      ; 00/161F
         STX $E7         ; Set address LBs
         LDA #$00        ; Bank: 00
         STA $E9         ; Set address HB
         LDX $00         ; 1st: Terra
C3CED3:  PHX             ; Save actor slot
         REP #$20        ; 16-bit A
         TXA             ; Get actor
         ASL A           ; Double it
         TAX             ; Index it
         LDA $1EDC       ; Eligible actors
         AND.L C3A456,X  ; Has our actor?
         BEQ C3CF00      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA $0000,X     ; Actor
         CMP #$0E        ; Guest?
         BCS C3CF00      ; Skip if so
         LDY $00         ; 1st: R-Hand
C3CEF2:  LDA [$E7],Y     ; Equipped item
         CMP $E0         ; Matches shop's?
         BNE C3CEFA      ; Branch if not
         INC $65         ; Quantity worn +1
C3CEFA:  INY             ; Gear slot +1
         CPY #$0006      ; Done all 6?
         BNE C3CEF2      ; Loop if not
C3CF00:  REP #$21        ; 16-bit A; C-
         LDA #$0025      ; Actor data size
         ADC $E7         ; Add SRAM pointer
         STA $E7         ; Set SRAM pointer
         SEP #$20        ; 8-bit A
         PLX             ; Actor slot
         INX             ; Point to next
         CPX #$0010      ; Done all 16?
         BNE C3CED3      ; Loop if not
         LDA $65         ; Quantity worn
         JSR C30563      ; Turn into text
         LDX #$7C3F      ; Text position
         JMP C30539      ; Draw 2 digits

; Get item by cursor in Buy menu
C3CF1D:  TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Item in slot
         RTS

; Get item selected in Sell menu
C3CF26:  TDC             ; Clear A
         LDA $4B         ; List slot
         TAY             ; Index it
         LDA $1869,Y     ; Item in slot
         RTS

; Draw shop title and define shop index
C3CF2E:  JSR C3D252      ; Color: Blue
C3CF31:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C3CF31      ; Loop if not
         LDA $0201       ; Shop number
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$09        ; Shop data size
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDX $2134       ; Index product
         STX $67         ; Set shop index
         LDA $C47AC0,X   ; Shop flags
         AND #$07        ; Title number
         ASL A           ; Double it
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA.L C3CF67,X  ; Text pointer
         STA $E7         ; Set src LBs
         SEP #$20        ; 8-bit A
         LDA #$C3        ; Bank: C3
         STA $E9         ; Set src HB
         JMP C3032C      ; Draw title

; Pointers to shop titles
C3CF67:  dw C30000       ; Bogus...
         dw C3D257       ; Weapon
         dw C3D25D       ; Armor
         dw C3D264       ; Item
         dw C3D26B       ; Relics
         dw C3D275       ; Vendor

; Set to condense BG3 text in shop menu
C3CF73:  LDA #$02        ; 1Rx2B to PPU
         STA $4350       ; Set DMA mode
         LDA #$12        ; $2112
         STA $4351       ; To BG3 V-Scroll
         LDY #C3CF92     ; C3/CF92
         STY $4352       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4354       ; Set src HB
         LDA #$C3        ; ...
         STA $4357       ; Set indir HB
         LDA #$20        ; Channel: 5
         TSB $43         ; Queue HDMA-5
         RTS

; BG3 text shifting table for shop
C3CF92:  db $2F,$04,$00  ; Title
         db $0C,$04,$00  ; Item 1
         db $0C,$08,$00  ; Item 2
         db $0C,$0C,$00  ; Item 3
         db $0C,$10,$00  ; Item 4
         db $0C,$14,$00  ; Item 5
         db $0C,$18,$00  ; Item 6
         db $0C,$1C,$00  ; Item 7
         db $0C,$20,$00  ; Item 8
         db $0C,$24,$00  ; Nothing
         db $0C,$28,$00  ; Nothing
         db $0C,$2C,$00  ; Nothing
         db $0C,$30,$00  ; Nothing
         db $0C,$34,$00  ; Nothing
         db $0C,$38,$00  ; Nothing
         db $0C,$3C,$00  ; Nothing
         db $00          ; End

; Load item's name
C3CFC3:  PHA             ; Save item
         LDX #$9E8B      ; 7E/9E8B
         STX $2181       ; Set WRAM LBs
C3CFCA:  LDA $4212       ; PPU status
         AND #$40        ; H-Blank?
         BEQ C3CFCA      ; Loop if not
         PLA             ; Item
         STA $211B       ; Set matrix A LB
         STZ $211B       ; Clear HB
         LDA #$09        ; Name data size		=== SNES: 13
         STA $211C       ; Set matrix B
         STA $211C       ; ...
         LDX $2134       ; Index product
         LDY #$0009      ; Letters: 9			=== SNES: 13
C3CFE6:  LDA $E6F700,X   ; Letter			=== SNES: $D2B300
         STA $2180       ; Add to string
         INX             ; Point to next
         DEY             ; One less left
         BNE C3CFE6      ; Loop till last
         STZ $2180       ; End string
         RTS

; Compile and create actors for Buy menu
C3CFF5:  JSR C3D064      ; Compile actors
         JSR C3D127      ; Mark members
         TDC             ; Clear A
         TAX             ; List slot: 1
C3CFFD:  LDA $7E9E09,X   ; Actor in slot
         BMI C3D047      ; Exit if none
         PHX             ; Save slot
         PHA             ; Save actor
         LDA #$02        ; Min slot: 16
         LDY #C3D09C     ; C3/D09C
         JSR C311DE      ; Queue OAM fn
         TXY             ; Queue slot
         TDC             ; Clear A
         PLA             ; Actor
         STA $7E35C9,X   ; Link to OBJ
         ASL A           ; Double it
         TAX             ; Index it
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $D8E9A1,X   ; Anim table ptr		=== SNES: $D8E917
         STA $32C9,Y     ; Set sprite's
         SEP #$20        ; 8-bit A
         PLX             ; List slot
         LDA.L C3D048,X  ; X position
         STA $33CA,Y     ; Set actor's
         LDA.L C3D056,X  ; Y position
         STA $344A,Y     ; Set actor's
         TDC             ; ...
         STA $33CB,Y     ; No use...
         STA $344B,Y     ; No use...
         LDA #$D8        ; Bank: D8
         STA $35CA,Y     ; Set ptr HB
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         INX             ; List slot +1
         BRA C3CFFD      ; Do next char
C3D047:  RTS

; X positions for shop actors
C3D048:  db $18          ; Actor 1
         db $38          ; Actor 2
         db $58          ; Actor 3
         db $78          ; Actor 4
         db $98          ; Actor 5
         db $B8          ; Actor 6
         db $D8          ; Actor 7
         db $18          ; Actor 8
         db $38          ; Actor 9
         db $58          ; Actor 10
         db $78          ; Actor 11
         db $98          ; Actor 12
         db $B8          ; Actor 13
         db $D8          ; Actor 14

; Y positions for shop actors
C3D056:  db $9C          ; Actor 1
         db $9C          ; Actor 2
         db $9C          ; Actor 3
         db $9C          ; Actor 4
         db $9C          ; Actor 5
         db $9C          ; Actor 6
         db $9C          ; Actor 7
         db $B8          ; Actor 8
         db $B8          ; Actor 9
         db $B8          ; Actor 10
         db $B8          ; Actor 11
         db $B8          ; Actor 12
         db $B8          ; Actor 13
         db $B8          ; Actor 14

; Compile actors for Buy menu
C3D064:  LDX #$9E09      ; 7E/9E09
         STX $2181       ; Set WRAM LBs
         LDX $00         ; 1st: Terra
C3D06C:  PHX             ; Save char slot
         REP #$20        ; 16-bit A
         TXA             ; Actor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA $1EDC       ; Showable chars
         AND.L C3A456,X  ; Has our actor?
         BEQ C3D08D      ; Skip if not
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         LDA $0000,Y     ; Actor
         CMP #$0E        ; Guest?
         BCS C3D08D      ; Skip if so
         STA $2180       ; Add to list
C3D08D:  SEP #$20        ; 8-bit A
         PLX             ; Actor slot
         INX             ; Slot +1
         CPX #$0010      ; Done all 16?
         BNE C3D06C      ; Loop if not
         LDA #$FF        ; Terminator
         STA $2180       ; End list
         RTS

; Update shop actor
C3D09C:  TAX             ; Index mode
         JMP (C3D0A0,X)  ; Handle mode

; Jump table for the above
C3D0A0:  dw C3D0A4       ; Initialize data
         dw C3D0C5       ; Sustain sprite

; Mode 0: Initialize data
C3D0A4:  LDA #$01        ; Hide actors: N
         TSB $47         ; Set menu flag
         LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA $32C9,X     ; Anim table ptr
         STA $34CA,X     ; Save original
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer
         LDA $47         ; Menu flags
         AND #$08        ; Shop mode?...
         BNE C3D0C3      ; Branch if not
         JSR C3D14B      ; Create big arrow
C3D0C3:  BRA C3D0C5      ; ...

; Mode 1: Sustain sprite
C3D0C5:  LDA $47         ; Menu flags
         AND #$01        ; Remove actors?
         BEQ C3D0F5      ; Delete if so
         LDX $2D         ; Queue index
         LDA $47         ; Menu flags
         AND #$08        ; Shop mode?...
         BNE C3D0E4      ; Branch if not
         JSR C3D0F7      ; Waving arms?
         BCC C3D0E4      ; Branch if not
         LDX $2D         ; Queue index
         REP #$21        ; 16-bit A; C-
         LDA $34CA,X     ; Base anim ptr
         ADC #$0009      ; Adjust value
         BRA C3D0EB      ; Set real ptr
C3D0E4:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $34CA,X     ; Base anim ptr
C3D0EB:  STA $32C9,X     ; Set as current
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C3D0F5:  CLC             ; Set to dequeue
         RTS

; Determine whether shop actor should wave its arms
C3D0F7:  PHB             ; Save DB
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         TDC             ; Clear A
         STA $11D8       ; No Merit Award
         LDA $7E35C9,X   ; Actor
         JSR C3A437      ; Define compat
         TDC             ; Clear A
         LDA $4B         ; Cursor slot
         TAX             ; Index it
         LDA $7E9D89,X   ; Item in slot
         JSR C38AA2      ; Compute index
         LDX $2134       ; Load it
         REP #$20        ; 16-bit A
         LDA $D85001,X   ; Compatibility
         AND $E7         ; Actor can use?
         SEP #$20        ; 8-bit A
         BEQ C3D124      ; Fail if not
         PLB             ; Restore DB
         SEC             ; Mark success
         RTS             ; Exit
C3D124:  PLB             ; Restore DB
         CLC             ; Mark failure
         RTS

; Compile party members for Buy menu
C3D127:  LDX #$9E01      ; 7E/9E01
         STX $2181       ; Set WRAM LBs
         LDX $00         ; Member index: 0
C3D12F:  REP #$20        ; 16-bit A
         LDA $006D,X     ; Actor's address
         SEP #$20        ; 8-bit A
         BEQ C3D13E      ; Skip if nobody
         TAY             ; Index it
         LDA $0000,Y     ; Actor in slot
         BRA C3D140      ; Skip a line
C3D13E:  LDA #$FF        ; Actor: None
C3D140:  STA $2180       ; Add to list
         INX             ; Member index +1
         INX             ; Member index +1
         CPX #$0008      ; Done 4 members?
         BNE C3D12F      ; Loop if not
         RTS

; Create arrow under shop actor if in party
C3D14B:  LDY $00         ; Member slot: 1
         LDX $2D         ; Queue index
C3D14F:  LDA $35C9,X     ; Shop actor
         CMP $9E01,Y     ; In member slot?
         BNE C3D18F      ; Try next if not
         PHX             ; Save queue index
         PHY             ; Save member slot
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         LDA #$00        ; Min slot: 0
         LDY #C382C9     ; C3/82C9
         JSR C311DE      ; Queue OAM fn
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         TDC             ; Clear A
         STA $35C9,X     ; No use...
         LDY $374A,X     ; Actor's index
         REP #$20        ; 16-bit A
         LDA $33CA,Y     ; Actor's X
         STA $33CA,X     ; Set arrow's
         LDA $344A,Y     ; Actor's Y
         DEC A           ; +1 px up
         DEC A           ; +1 px up
         STA $344A,X     ; Set arrow's Y
         LDA #$EC33      ; Anim table ptr		=== SNES: D8/EBA9
         STA $32C9,X     ; Set arrow's
         SEP #$20        ; 8-bit A
         LDA #$D8        ; Bank: D8
         STA $35CA,X     ; Set ptr HB
         PLY             ; Member slot
         PLX             ; Queue index
C3D18F:  INY             ; Member slot +1
         CPY #$0004      ; Done all 4?
         BNE C3D14F      ; Loop if not
         RTS

; Create sign by each actor in Buy menu
C3D196:  TDC             ; Clear A
         TAY             ; Char slot: 1
C3D198:  PHY             ; Save char slot
         LDA #$04        ; Min slot: 32
         LDY #C3D1AE     ; C3/D1AE
         JSR C311DE      ; Queue OAM fn
         PLY             ; Char slot
         TYA             ; Put in A
         STA $7E35C9,X   ; Assign to sign
         INY             ; Char slot +1
         CPY #$000E      ; Done all 14?
         BNE C3D198      ; Loop if not
         RTS

; Update shop sign
C3D1AE:  TAX             ; Index mode
         JMP (C3D1B2,X)  ; Handle mode

; Jump table for the above
C3D1B2:  dw C3D1B6       ; Initialize sprite
         dw C3D1E6       ; Sustain sprite

; Mode 0: Initialize sprite
C3D1B6:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA #$EC57      ; Anim table ptr		=== SNES: D8/EBCD
         STA $32C9,X     ; Set current
         STA $34CA,X     ; Set original
         SEP #$20        ; 8-bit A
         INC $3649,X     ; Mode +1
         LDA #$D8        ; Bank: D8
         STA $35CA,X     ; Set ptr HB
         TDC             ; Clear A
         LDA $35C9,X     ; Char slot
         TXY             ; Queue index
         TAX             ; Index slot
         LDA $D8EC3B,X   ; X position			=== SNES: $D8EBB1
         STA $33CA,Y     ; Set sign's
         LDA $D8EC49,X   ; Y position			=== SNES: $D8EBBF
         STA $344A,Y     ; Set sign's
         LDX $2D         ; Queue index
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3D1E6:  LDA $47         ; Menu flags
         AND #$01        ; Actors shown?
         BEQ C3D23A      ; Delete if not
         LDX $2D         ; Queue index
         TDC             ; ...
         LDA $35C9,X     ; Char slot
         STA $E0         ; Memorize it
         JSR C3CC09      ; Sign
         BEQ C3D238      ; Exit if none
         CMP #$01        ; Equipped?
         BEQ C3D211      ; Branch if so
         CMP #$02        ; Up?
         BEQ C3D226      ; Branch if so
         CMP #$04        ; Equal?
         BEQ C3D21A      ; Branch if so

; Fork: Down sign
C3D205:  LDX $2D         ; Queue index
         REP #$21        ; 16-bit A; C-
         LDA $34CA,X     ; Base anim ptr
         ADC #$0018      ; Adjust value
         BRA C3D230      ; Set real ptr

; Fork: Equipped sign
C3D211:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $34CA,X     ; Base anim ptr
         BRA C3D230      ; Set as current

; Fork: Equal sign
C3D21A:  LDX $2D         ; Queue index
         REP #$21        ; 16-bit A; C-
         LDA $34CA,X     ; Base anim ptr
         ADC #$0024      ; Adjust value
         BRA C3D230      ; Set real ptr

; Fork: Up sign
C3D226:  LDX $2D         ; Queue index
         REP #$21        ; 16-bit A; C-
         LDA $34CA,X     ; Base anim ptr
         ADC #$000C      ; Adjust value
C3D230:  STA $32C9,X     ; Set real ptr
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
C3D238:  SEC             ; Set to requeue
         RTS

; Fork: Delete sign
C3D23A:  CLC             ; Set to dequeue
         RTS

; Draw "Owned:" and "Equipped:" for Buy menu
C3D23C:  JSR C3D252      ; Color: Blue
         LDY #C3D295     ; Text pointer
         JSR C30326      ; Draw "Owned:"
         LDY #C3D29F     ; Text pointer
         JSR C30326      ; Draw "Equipped:"
         BRA C3D24D      ; ...

; Set text color to player's color
C3D24D:  LDA #$20        ; Palette 0
         STA $29         ; Color: User's
         RTS

; Set text color to blue
C3D252:  LDA #$2C        ; Palette 3
         STA $29         ; Color: Blue
         RTS

; Positioned text for shop menu						=== SNES: +40h as no diacritics; some positions differ
C3D257:  dw $78CF : db |ぶきや[end]|			; Weapon
C3D25D:  dw $78CF : db |ぼうぐや[end]|			; Armor
C3D264:  dw $78CF : db |どうぐや[end]|			; Item
C3D26B:  dw $78CD : db |アクセサリーや[end]|			; Relics
C3D275:  dw $78CD : db |ぎょうしょう[end]|			; Vendor
C3D27E:  dw $79CF : db |かう  うる  でる[end]|			; BUY  SELL  EXIT
C3D28B:  dw $7A01 : db |ギル[end]|			; GP (owned)
C3D290:  dw $7AEB : db |ギル[end]|			; GP (trade)
C3D295:  dw $7A73 : db |もっているかず[end]|			; Owned:
C3D29F:  dw $7B73 : db |そうびしているかず[end]|			; Equipped:
C3D2AB:  dw $7B55 : db |こうげきりょく ‥[end]|			; Bat Pwr
C3D2B7:  dw $7B55 : db |ぼうぎょ[end]|			; Defense
C3D2BE:  dw $7BA5 : db |‥[end]|				; ‥					=== SNES: "…"
C3D2C2:  dw $78DF : db |「いらっしゃい!どんなごようけんで?」[end]|		; Hi! Can I help you?
C3D2D8:  dw $78DF : db |「なにが ほしいんだいっ!?」    [end]|	; Help yourself!
C3D2EE:  dw $78DF : db |「いくつ ほしいんだいっ!?」[end]|		; How many?
C3D300:  dw $78DF : db |「なにを うりたいんだい?」     [end]|	; Whatcha got?
C3D316:  dw $78DF : db |「いくつ うりたいんだい?」[end]|		; How many?
C3D327:  dw $78DF : db |「まいど どーも!」         [end]|	; "Bye!          "
C3D33D:  dw $78DF : db |「‥‥おかねが たりないようだね」[end]|		; You need more GP!
C3D351:  dw $78DF : db |「もう もてないよ」     [end]|		; "Too many!       "
C3D363:  dw $78DF : db |「１つあれば じゅうぶんだよ」[end]|		; "One's plenty! "

; =============================================================================

; Jump table for ending sequences
C3D375:  dw C3D52D       ; 00: Fade screen before ending scene
         dw C3D543       ; 01: Return to event script
         dw C3D7DB       ; 02: Show aerial-view panning clouds
         dw C3D81B       ; 03: Wait before fading screen
         dw C3D822       ; 04: Show spinning clouds
         dw C3D550       ; 05: Start sideview airship scene
         dw C3D5F3       ; 06: Bogus...
         dw C3D64E       ; 07: Bogus...
         dw C3D64E       ; 08: Bogus...
         dw C3D706       ; 09: Start aerial-view airship scene
         dw C3D744       ; 0A: Show aerial-view airship
         dw C3D753       ; 0B: Fade screen to white
         dw C3D849       ; 0C: Start boat scene
         dw C3D88F       ; 0D: Show boat sprite
         dw C3D945       ; 0E: Bogus...
         dw C3D945       ; 0F: Bogus...
         dw C3D945       ; 10: Start skimming airship scene
         dw C3DA07       ; 11: Show swooping bird
         dw C3DA39       ; 12: Unused...
         dw C3DA39       ; 13: Unused...
         dw C3DC92       ; 14: Start frontview airship scene
         dw C3DD1E       ; 15: Show late bird flock
         dw C3DD68       ; 16: Bogus...
         dw C3DD68       ; 17: Bogus...
         dw C3DE24       ; 18: Start aerial-view plains scene
         dw C3DE6D       ; 19: Bogus...
         dw C3DE6D       ; 1A: Bogus...
         dw C3DE6D       ; 1B: Bogus...
         dw C3DE6D       ; 1C: Start rearview airship scene
         dw C3DF9C       ; 1D: Bogus...
         dw C3DF9C       ; 1E: Bogus...
         dw C3DF9C       ; 1F: Bogus...
         dw C3DFB3       ; 20: Start final airship scene
         dw C3E01A       ; 21: Fade final airship
         dw C3E0A6       ; 22: Bogus...
         dw C3E0A6       ; 23: Bogus...
         dw C3E0A6       ; 24: Bogus...
         dw C3D706       ; 25: Bogus...
         dw C3D706       ; 26: Bogus...
         dw C3D706       ; 27: Bogus...
         dw C3F1A8       ; 28: Start Shadow's scene
         dw C3F1EC       ; 29: Fade in "Shadow as"
         dw C3F1FB       ; 2A: Switch Shadow's names
         dw C3F20A       ; 2B: Fade all but Shadow's name
         dw C3D706       ; 2C: Bogus...
         dw C3F608       ; 2D: Start first book scene
         dw C3F619       ; 2E: Animate first book
         dw C3F628       ; 2F: Wait 480 frames
         dw C3F634       ; 30: Pixelate and fade first book
         dw C3D706       ; 31: Bogus...
         dw C3F232       ; 32: Start Cyan's scene
         dw C3F253       ; 33: Fade in "Cyan as"
         dw C3F262       ; 34: Switch Cyan's names
         dw C3F271       ; 35: Fade all but Cyan's name
         dw C3D706       ; 36: Bogus...
         dw C3D706       ; 37: Bogus...
         dw C3F221       ; 38: Fade actor's true name
         dw C3D706       ; 39: Bogus...
         dw C3D706       ; 3A: Bogus...
         dw C3D706       ; 3B: Bogus...
         dw C3F31B       ; 3C: Start Mog's scene
         dw C3F337       ; 3D: Fade in "Mog as"
         dw C3F346       ; 3E: Switch Mog's names
         dw C3F355       ; 3F: Fade all but Mog's name
         dw C3F285       ; 40: Start Edgar and Sabin's scene
         dw C3F29E       ; 41: Fade in "Edgar as"
         dw C3F2AD       ; 42: Switch Edgar's names
         dw C3F2BC       ; 43: Show Sabin's name, fade Edgar's
         dw C3F2DC       ; 44: Delete Edgar's name
         dw C3F2EC       ; 45: Switch Sabin's names
         dw C3F36C       ; 46: Start Gogo's scene
         dw C3F393       ; 47: Fade in "Gogo as"
         dw C3F3B6       ; 48: Switch Gogo's names
         dw C3F3C5       ; 49: Fade all but Gogo's name
         dw C3F64B       ; 4A: Start last book scene
         dw C3F664       ; 4B: Wait 180 frames
         dw C3F670       ; 4C: Stop last book and fade in text
         dw C3F683       ; 4D: Pixelate and fade last book
         dw C3D706       ; 4E: Bogus...
         dw C3F307       ; 4F: Fade all but Sabin's name
         dw C3F434       ; 50: Start Gau's scene
         dw C3F44D       ; 51: Fade in "Gau as"
         dw C3F45C       ; 52: Switch Gau's names; create face
         dw C3F46E       ; 53: Fade all but Gau's name
         dw C3D706       ; 54: Bogus...
         dw C3D706       ; 55: Bogus...
         dw C3D706       ; 56: Bogus...
         dw C3D706       ; 57: Bogus...
         dw C3D706       ; 58: Bogus...
         dw C3D706       ; 59: Bogus...
         dw C3F485       ; 5A: Start Terra's scene
         dw C3F49E       ; 5B: Fade in "Terra as"
         dw C3F4AD       ; 5C: Switch Terra's names, create glint
         dw C3F4BF       ; 5D: Fade all but Terra's name
         dw C3D706       ; 5E: Bogus...
         dw C3D706       ; 5F: Bogus...
         dw C3D706       ; 60: Bogus...
         dw C3D706       ; 61: Bogus...
         dw C3D706       ; 62: Bogus...
         dw C3D706       ; 63: Bogus...
         dw C3F4D6       ; 64: Start Locke and Celes's scene
         dw C3F4F1       ; 65: Fade in "Locke as"
         dw C3F500       ; 66: Switch Locke's names
         dw C3F50F       ; 67: Show Celes's name, fade Locke's
         dw C3F52F       ; 68: Delete Locke's name
         dw C3F53F       ; 69: Switch Celes's names
         dw C3F558       ; 6A: Fade all but Celes's name
         dw C3D706       ; 6B: Bogus...
         dw C3D706       ; 6C: Bogus...
         dw C3D706       ; 6D: Bogus...
         dw C3F56F       ; 6E: Start Relm's scene
         dw C3F58B       ; 6F: Fade in "Relm as"
         dw C3F59A       ; 70: Switch Relm's names
         dw C3F5A9       ; 71: Fade all but Relm's name
         dw C3D706       ; 72: Bogus...
         dw C3D706       ; 73: Bogus...
         dw C3D706       ; 74: Bogus...
         dw C3D706       ; 75: Bogus...
         dw C3D706       ; 76: Bogus...
         dw C3D706       ; 77: Bogus...
         dw C3F5C0       ; 78: Start Strago's scene
         dw C3F5D6       ; 79: Fade in "Strago as"
         dw C3F5E5       ; 7A: Switch Strago's names
         dw C3F5F4       ; 7B: Fade all but Strago's name
         dw C3D706       ; 7C: Bogus...
         dw C3D706       ; 7D: Bogus...
         dw C3D706       ; 7E: Bogus...
         dw C3D706       ; 7F: Bogus...
         dw C3D706       ; 80: Bogus...
         dw C3D706       ; 81: Bogus...
         dw C3F697       ; 82: Start Setzer's scene
         dw C3F6CE       ; 83: Fade in "Setzer as"
         dw C3F6DD       ; 84: Switch Setzer's names
         dw C3F6EC       ; 85: Fade background
         dw C3F6FB       ; 86: Fade cards and name
         dw C3F71F       ; 87: Start Umaro's scene
         dw C3F73E       ; 88: Fade in "Umaro as"
         dw C3F74D       ; 89: Switch Umaro's names
         dw C3F75C       ; 8A: Fade all but Umaro's name

; Display requested ending cinematic
C3D48B:  PHP             ; Push PS
         REP #$30        ; 16-bit A, X, Y
         PHA             ; ...
         PHX             ; ...
         PHY             ; Push Y
         PHB             ; Push DB
         PHD             ; Push DP
         SEP #$20        ; 8-bit A
         LDA #$00        ; Zero A
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDX #$0000      ; Clear X
         PHX             ; Put on stack
         PLD             ; Set DP to 0
         LDX #$0000      ; ...
         STX $00         ; ...
         LDA #$7E        ; Bank: 7E
         STA $2183       ; Set WRAM HB
         JSR C300C0      ; Reroute NMI/IRQ
         JSR C3706C      ; Reset variables
         LDY #$012C      ; Scroll delay: 300
         STY $85         ; For true char name
         STZ $B4         ; Blue credits: N
         JSR C3D4F5      ; Stop VRAM DMA
         JSR C3D4E5      ; Disable pad, etc.
         JSL $D4CD48     ; Init registers
         JSL C3AC4F      ; Init joypad...
         JSR C3117F      ; Reset OAM, queue
         JSR C3ECC3      ; Clear VRAM
         JSL $D4CF3B     ; Back up data
         LDA $0201       ; Event parameter
         STA $26         ; Set scene mode
         JSR C3D514      ; Handle scene
         JSL $D4CF4B     ; Restore backup
         JSR C3D4E5      ; Disable pad, etc.
         REP #$30        ; 16-bit A, X, Y
         PLD             ; Pull DP
         PLB             ; Pull DB
         PLY             ; Pull Y
         PLX             ; ...
         PLA             ; ...
         PLP             ; Pull PS
         RTL

; Disable screen, interrupts, joypad, and HDMA
C3D4E5:  LDA #$8F        ; BRT: 15 and OFF
         STA $2100       ; Disable screen
         TDC             ; Clear A
         STA $4200       ; Disable INT, pad
         STA $420B       ; Disable DMA...
         STA $420C       ; Disable HDMA
         RTS

; Reset variables for automatic uploads during NMI
C3D4F5:  TDC             ; Clear A
         TAY             ; Clear Y
         STY $1B         ; Halt VRAM B
         STY $1D         ; Clear src-B LBs
         STA $1F         ; Clear src-B HB
         STY $16         ; Clear src-A LBs
         STA $18         ; Clear src-A HB
         LDY #$0001      ; Bytes: 1
         STY $19         ; Set data size B
         STY $12         ; Set data size A
         LDY #$7FFF      ; $7FFF
         STY $14         ; Set VRAM ptr A
         RTS

; Enable color addition on BG1
C3D50E:  LDA #$01        ; BG1: ADD mode
         STA $2131       ; Set register
         RTS

; Handle ending sequence
C3D514:  TDC             ; Clear A
         LDA $26         ; Scene mode
         CMP #$FF        ; Exit to map?
         BEQ C3D52C      ; Exit if so
         REP #$20        ; 16-bit A
         ASL A           ; Double it
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         JSR (C3D375,X)  ; Handle mode
         JSR C3121B      ; Run anim queue
         JSR C313D3      ; Refresh screen
         BRA C3D514      ; Loop
C3D52C:  RTS

; 00: Fade screen before ending scene
C3D52D:  LDY $20         ; Delay expired?
         BNE C3D542      ; Exit if not
         LDA #$01        ; C3/D543
         STA $26         ; Next: Exit
         LDY #$000F      ; Frames: 15
         STY $20         ; Set exit delay
         LDA #$00        ; Min slot: 0
         LDY #C3E181     ; C3/E181
         JSR C311DE      ; Queue fade-out
C3D542:  RTS

; 01: Return to event script after delay
C3D543:  LDY $20         ; Delay expired?
         BNE C3D54A      ; Exit if not
         JMP C3F1A3      ; End scene
C3D54A:  RTS

; Set text for credits to be blue
C3D54B:  LDA #$01        ; Blue text: Y
         STA $B4         ; Set color mode
         RTS

; 05: Start sideview airship scene
C3D550:  JSR C3D54B      ; Blue text: Y
         JSL $D4CED7     ; Init registers
         JSR C3E39C      ; Upload GFX, map
         JSR C3E376      ; Reset M7 vars
         JSL $D4CBFC     ; Queue HDMA 1-7
         LDY #$0010      ; Zoom-out: 16
         STY $8E         ; Set for airship
         REP #$20        ; 16-bit A
         LDA #$FFF1      ; H-Scroll: -15
         STA $7EB68D     ; Set for airship
         LDA #$002E      ; V-Scroll: 46
         STA $7EB68F     ; Set for airship
         LDA #$0071      ; Center X: 113
         STA $7EB695     ; Set for airship
         LDA #$008D      ; Center Y: 141
         STA $7EB697     ; Set for airship
         SEP #$20        ; 8-bit A
         LDY #$005E      ; Vertical angle
         STY $C7         ; Set for clouds
         LDY #$2F00      ; Base divisor
         STY $C5         ; Set matrices'
         LDY #$0100      ; Center X: 256
         STY $B7         ; Set for clouds
         LDY #$0311      ; Center Y: 785
         STY $B9         ; Set for clouds
         LDY #$0080      ; BG1's X: 128
         STY $35         ; Set for clouds
         LDY #$0291      ; BG1's Y: 657
         STY $37         ; Set for clouds
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         JSR C3E8C8      ; Build text OAM
         LDA #$02        ; Min slot: 16
         LDY #C3E71E     ; C3/E71E
         JSR C311DE      ; Queue credits
         LDA #$02        ; Min slot: 16
         LDY #C3D5F3     ; C3/D5F3
         JSR C311DE      ; Queue M7 anim
         LDA #$00        ; Min slot: 0
         LDY #C3E076     ; C3/E076
         JSR C311DE      ; Queue rotor anim
         JSR C3E0E0      ; Make text black
         JSR C3E0F7      ; Load cloud colors
         JSR C3DF9C      ; Load sky/plane's
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Fade-out
         LDY #$021C      ; Frames: 540
         STY $20         ; Set fade delay
         JMP C3D5DE      ; ...

; Queue field fade-in
C3D5DE:  LDA #$00        ; Min slot: 0
         LDY #C3E150     ; C3/E150
         JSR C311DE      ; Queue fade-in
         RTS

; Set brightness before fading in colors manually
C3D5E7:  LDA #$01        ; BRT: 1 and ON
         STA $44         ; Set brightness
         JSR C313D3      ; Refresh screen
         LDA #$0F        ; BRT: 15 and ON
         STA $44         ; Set brightness
         RTS

; Shrink sideview airship and scroll clouds
C3D5F3:  TAX             ; Index mode
         JMP (C3D5F7,X)  ; Handle mode

; Jump table for the above
C3D5F7:  dw C3D5FD       ; Initialize unused timer
         dw C3D60C       ; Shrink airship, scroll clouds
         dw C3D62C       ; Scroll clouds

; Mode 0: Initialize unused timer...
C3D5FD:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$024E      ; Frames: 590
         STA $3349,X     ; Set mode timer
         SEP #$20        ; 8-bit A

; Mode 1: Shrink airship, scroll clouds
C3D60C:  LDX $2D         ; Queue index
         LDA $23         ; NMI count
         AND #$01        ; Odd value?
         BNE C3D618      ; Branch if so
         REP #$20        ; 16-bit A
         INC $8E         ; Matrix A +1
C3D618:  REP #$20        ; 16-bit A
         LDA $8E         ; Matrix A
         STA $0600       ; Set for airship
         STZ $07C2       ; Matrix B: 0
         STZ $0984       ; Matrix C: 0
         JSR C3D631      ; Scroll clouds
         SEP #$20        ; ...
         SEC             ; Set to requeue
         RTS

; Mode 2: Scroll clouds (unused)
C3D62C:  JSR C3D631      ; Scroll clouds
         SEC             ; Set to requeue
         RTS

; Scroll clouds under sideview airship
C3D631:  REP #$20        ; 16-bit A
         DEC $35         ; BG1's X -1
         DEC $B7         ; Center X -1
         LDA $35         ; BG1 X-Pos
         STA $B691       ; To HDMA table
         LDA $37         ; BG1 Y-Pos
         STA $B693       ; To HDMA table
         LDA $B7         ; Center X
         STA $B699       ; To HDMA table
         LDA $B9         ; Center Y
         STA $B69B       ; To HDMA table
         SEP #$20        ; 8-bit A
         RTS

; Set to fade credits
C3D64E:  LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Do big font
         LDA #$C3        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$31E9      ; To OBJ pal 5
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Do small font
         RTS

; Set to fade in credits to white and blue
C3D675:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #$974C      ; C2/974C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do big font
         LDA #$C2        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$31E9      ; To OBJ pal 5
         STY $E7         ; ...
         LDX #$9744      ; C2/9744			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do small font
         RTS

; Set to fade in credits to dark blue
C3D69C:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #$973C      ; C2/973C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do big font
         LDA #$C2        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$31E9      ; To OBJ pal 5
         STY $E7         ; ...
         LDX #$9734      ; C2/9734			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do small font
         RTS

; Load non-text sprite colors for Mode 7 scene
C3D6C3:  LDA #$C2        ; Source HB
         LDY #$3149      ; To OBJ pal 0
         LDX #$97EC      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Do balloon's
         LDA #$C2        ; Source HB
         LDY #$3169      ; To OBJ pal 1
         LDX #$978C      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Do airships'
         LDA #$C2        ; Source HB
         LDY #$3189      ; To OBJ pal 2
         LDX #$97AC      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Do boat's
         LDA #$C2        ; Source HB
         LDY #$31A9      ; To OBJ pal 3
         LDX #$97CC      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Do cockpit's
         LDA #$C2        ; Source HB
         LDY #$3209      ; To OBJ pal 6
         LDX #$982C      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Do gray birds'
         LDA #$C2        ; Source HB
         LDY #$3229      ; To OBJ pal 7
         LDX #$980C      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Do spray's
         RTS

; 09: Start aerial-view airship scene
C3D706:  JSR C3D54B      ; Blue text: Y
         JSL $D4CED7     ; Init registers
         JSR C3E487      ; Upload GFX, map
         JSR C3E376      ; Reset M7 vars
         JSL $D4CB8F     ; HDMA: Matrices
         JSR C3D6C3      ; Load OBJ colors
         JSR C3E0E0      ; Make text black
         JSR C3E0F7      ; Load cloud colors
         LDY #$8A60      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue cloud anim
         JSR C3E8DE      ; Build text OAM
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         LDA #$02        ; Min slot: 16
         LDY #C3E730     ; C3/E730
         JSR C311DE      ; Queue credits
         JSR C3E224      ; Queue M7 handler
         INC $26         ; Next: C3/D744
         LDY #$03C0      ; Frames: 960
         STY $20         ; Set plane delay
         JMP C3D5DE      ; Queue fade-in

; 0A: Show aerial-view airship and its shadow
C3D744:  LDY $20         ; Delay expired?
         BNE C3D752      ; Exit if not
         INC $26         ; Next: C3/D753
         LDY #$0870      ; Frames: 2160
         STY $20         ; Set fade delay
         JSR C3D774      ; Create sprites
C3D752:  RTS

; 0B: Fade screen to white
C3D753:  LDY $20         ; Delay expired?
         BNE C3D773      ; Exit if not
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Black out
         LDY #$0078      ; Frames: 120
         STY $20         ; Set fade delay
         LDA #$C3        ; Bank: C3
         STA $ED         ; Set src HB
         LDA #$02        ; Slowness: 2
         LDY #$30A9      ; To BG pal 3
         STY $E7         ; ...
         LDX #C3113F     ; White palette
         STX $EB         ; ...
         JSR C31015      ; Whiten clouds
C3D773:  RTS

; Create aerial-view airship and its shadow
C3D774:  JSR C3D7B8      ; Queue ship fn
         REP #$20        ; 16-bit A
         LDA #$8CCC      ; Ship anim ptr		=== SNES address differs
         JSR C3D7C1      ; Set spd, timer
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$F8        ; X: 248
         STA $7E33CA,X   ; Set airship's
         LDA #$A0        ; Y: 160
         STA $7E344A,X   ; Set airship's
         LDA #$03        ; Min slot: 24
         LDY #C3EDD4     ; C3/EDD4
         JSR C311DE      ; Queue shadow fn
         REP #$20        ; 16-bit A
         LDA #$8CE0      ; Shadow anim ptr		=== SNES address differs
         JSR C3D7C1      ; Set spd, timer
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$F8        ; X: 248
         STA $7E33CA,X   ; Set shadow's
         LDA #$B0        ; Y: 176
         STA $7E344A,X   ; Set shadow's
         RTS

; Queue linearly moving temporary sprite
C3D7B8:  LDA #$01        ; Min slot: 8
         LDY #C3EDD4     ; C3/EDD4
         JSR C311DE      ; Queue OAM fn
         RTS

; Initialize data for aerial-view airship or its shadow
C3D7C1:  STA $7E32C9,X   ; Set anim ptr
         LDA #$FFC0      ; H-Spd: -0.25 px
         STA $7E34C9,X   ; Set sprite's
         LDA #$FFE0      ; V-Spd: -0.125 px
         STA $7E3549,X   ; Set sprite's
         LDA #$0400      ; Frames: 1024
         STA $7E3349,X   ; Set hide delay
         RTS

; 02: Show aerial-view panning clouds
C3D7DB:  JSR C3D7F0      ; Load map, etc.
         LDY #$00F0      ; Frames: 240
         STY $20         ; Set fade delay
         LDY #$8B2C      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue cloud anim
         INC $26         ; Next: Fade-out
         JMP C3D5DE      ; Queue fade-in

; Initialize data for spinning or panning clouds
C3D7F0:  JSL $D4CED7     ; Init registers
         JSR C3E487      ; Upload GFX, map
         JSR C3E376      ; Reset M7 vars
         JSL $D4CB8F     ; HDMA: Matrices
         JSR C3D6C3      ; Load OBJ colors
         JSR C3E0E0      ; Make text black
         LDY #$0200      ; Vertical angle
         STY $C7         ; Set for clouds
         LDY #$F000      ; Base divisor
         STY $C5         ; Set matrices'
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         JSR C3E0F7      ; Load cloud colors
         JSR C3E224      ; Queue M7 handler
         RTS

; 03: Wait before fading screen
C3D81B:  LDY $20         ; Delay expired?
         BNE C3D821      ; Exit if not
         STZ $26         ; Next: Fade-out
C3D821:  RTS

; 04: Show spinning clouds
C3D822:  JSR C3D7F0      ; Load map, etc.
         LDY #$8000      ; Vertical angle
         STY $C7         ; Set for clouds
         LDY #$8000      ; Base divisor
         STY $C5         ; Set matrices'
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         LDY #$0078      ; Frames: 120
         STY $20         ; Set fade delay
         LDY #$8B32      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue cloud anim
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Fade-out
         JMP C3D5DE      ; Queue fade-in

; 0C: Start boat scene
C3D849:  JSL $D4CED7     ; Init registers
         JSR C3D50E      ; Color math: BG1
         JSR C3E50F      ; Upload GFX, map
         JSR C3E376      ; Reset M7 vars
         JSL $D4CB8F     ; HDMA: Matrices
         LDY #$1000      ; Base divisor
         STY $C5         ; Set matrices'
         JSR C3E0E0      ; Make text black
         JSR C3E0F7      ; Load BG1 colors
         JSR C3D6C3      ; Load OBJ colors
         LDY #$8AC9      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue sea anim
         JSR C3DA42      ; Create birds
         JSR C3E8F4      ; Build text OAM
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         LDA #$02        ; Min slot: 16
         LDY #C3E77E     ; C3/E77E
         JSR C311DE      ; Queue credits
         JSR C3E224      ; Queue M7 handler
         LDY #$0438      ; Delay: 1080
         STY $20         ; Set boat OBJ's
         INC $26         ; Next: C3/D88F
         JMP C3D5DE      ; Queue fade-in

; 0D: Show boat sprite
C3D88F:  LDY $20         ; Delay expired?
         BNE C3D89D      ; Exit if not
         JSR C3D8C6      ; Create boat
         STZ $26         ; Next: Fade-out
         LDY #$02D0      ; Frames: 720
         STY $20         ; Set fade delay
C3D89D:  RTS

; Create boat sprite (unused)
C3D89E:  JSR C3F90C      ; Queue OAM fn
         REP #$20        ; 16-bit A
         LDA #$F7AD      ; Anim table ptr		=== SNES: CF/F7FD
         STA $7E32C9,X   ; Set sprite's
         LDA #$FFC0      ; H-Spd: -0.25 px
         STA $7E34C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$F8        ; X: 248
         STA $7E33CA,X   ; Set sprite's
         LDA #$70        ; Y: 112
         STA $7E344A,X   ; Set sprite's
         RTS

; Create boat sprite
C3D8C6:  JSR C3F90C      ; Queue L-Half
         REP #$20        ; 16-bit A
         LDA #$F7B9      ; Anim table ptr		=== SNES: CF/F809
         STA $7E32C9,X   ; Set L-Half's
         LDA #$FFC0      ; H-Spd: -0.25 px
         STA $7E34C9,X   ; Set L-Half's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$F8        ; X: 248
         STA $7E33CA,X   ; Set L-Half's
         LDA #$50        ; Y: 80
         STA $7E344A,X   ; Set L-Half's
         LDA #$01        ; Min slot: 8
         LDY #C3D91A     ; C3/D91A
         JSR C311DE      ; Queue R-Half
         REP #$20        ; 16-bit A
         LDA #$F7AD      ; Anim table ptr		=== SNES: CF/F7FD
         STA $7E32C9,X   ; Set R-Half's
         LDA #$FFC0      ; H-Spd: -0.25 px
         STA $7E34C9,X   ; Set R-Half's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$F8        ; X: 248
         STA $7E33CA,X   ; Set R-Half's
         LDA #$50        ; Y: 80
         STA $7E344A,X   ; Set R-Half's
         RTS

; Animate boat's right half
C3D91A:  TAX             ; Index mode
         JMP (C3D91E,X)  ; Handle mode

; Jump table for the above
C3D91E:  dw C3D922       ; Initialize timers
         dw C3D934       ; Sustain sprite

; Mode 0: Initialize timers
C3D922:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$0040      ; Frames: 64
         STA $3349,X     ; Set show delay
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3D934:  LDX $2D         ; Queue index
         LDY $3349,X     ; Delay expired?
         BNE C3D940      ; Branch if not
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C3D940:  JSR C3DF69      ; Delay -1
         SEC             ; Set to requeue
         RTS

; 10: Start skimming airship scene
C3D945:  JSL $D4CED7     ; Init registers
         JSR C3D50E      ; Color math: BG1
         JSR C3E53F      ; Upload GFX, map
         JSR C3D9EC      ; Get sky; init M7
         JSR C3E337      ; Queue gradient
         JSR C3E31A      ; HDMA: Color math
         JSR C3D6C3      ; Load OBJ colors
         LDY #$0028      ; Y: 40
         STY $3B         ; Set BG2 Y-Pos
         LDY #$FF6D      ; Mod index: 109
         STY $C3         ; Set matrices'
         LDY #$034C      ; Vertical angle
         STY $C7         ; Set for sea
         LDY #$FD00      ; Base divisor
         STY $C5         ; Set matrices'
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         JSR C3DA78      ; Create birds
         LDA #$02        ; Min slot: 16
         LDY #C3DB41     ; C3/DB41
         JSR C311DE      ; Queue airship
         REP #$20        ; 16-bit A
         LDA #$8BA1      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set airship's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$78        ; X: 120
         STA $7E33CA,X   ; C3/DB56...
         LDA #$58        ; Base Y/2: 88
         STA $7E344A,X   ; C3/DB5B...
         JSR C3F90C      ; Queue shadow
         REP #$20        ; 16-bit A
         LDA #$8BDC      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set shadow's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$80        ; X: 128
         STA $7E33CA,X   ; Set shadow's
         LDA #$80        ; Y: 128
         STA $7E344A,X   ; Set shadow's
         JSR C3E0F7      ; Load sea colors
         JSR C3E90A      ; Build text OAM
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         LDA #$02        ; Min slot: 16
         LDY #C3E7AE     ; C3/E7AE
         JSR C311DE      ; Queue credits
         LDY #$8B26      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue sea anim
         LDA #$03        ; Min slot: 24
         LDY #C3DA1D     ; C3/DA1D
         JSR C311DE      ; Set to pan sky
         JSR C3E224      ; Queue M7 handler
         INC $26         ; Next: Late bird
         LDY #$04B0      ; Frames: 1200
         STY $20         ; Set bird's delay
         JMP C3D5DE      ; Queue fade-in

; Load cloudy sky graphics data, exclude sky from Mode 7
C3D9EC:  JSR C3E376      ; Reset M7 vars
         JSR C3E438      ; Load GFX, map
         JSR C3E2F6      ; Set up M7 HDMA
         JSR C3E0E0      ; Make text black
         JMP C3D9FB      ; ...
C3D9FB:  LDA #$C2        ; Source HB
         LDY #$3049      ; To BG pal 0
         LDX #$9534      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Load sky colors
         RTS

; 11: Show swooping bird
C3DA07:  LDY $20         ; Delay expired?
         BNE C3DA1C      ; Exit if not
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Fade-out
         LDY #$0708      ; Frames: 1800
         STY $20         ; Set fade delay
         LDA #$01        ; Min slot: 8
         LDY #C3DBF4     ; C3/DBF4
         JSR C311DE      ; Queue bird OAM
C3DA1C:  RTS

; Scroll sky eastward
C3DA1D:  LDA $23         ; NMI count
         AND #$01        ; Odd value?
         BNE C3DA29      ; Exit if so
         REP #$20        ; 16-bit A
         DEC $39         ; BG2 camera -1
         SEP #$20        ; 8-bit A
C3DA29:  SEC             ; Set to requeue
         RTS

; Scroll sky westward
C3DA2B:  LDA $23         ; NMI count
         AND #$01        ; Odd value?
         BNE C3DA37      ; Exit if so
         REP #$20        ; 16-bit A
         INC $39         ; BG2 camera +1
         SEP #$20        ; 8-bit A
C3DA37:  SEC             ; Set to requeue
         RTS

; 12-13: Return to event script after delay (unused variant)
C3DA39:  LDY $20         ; Delay expired?
         BNE C3DA41      ; Exit if not
         LDA #$FF        ; Null value
         STA $26         ; Next: Exit
C3DA41:  RTS

; Create birds for boat scene
C3DA42:  LDX $00         ; ROM index: 0
C3DA44:  PHX             ; Save ROM index
         JSR C3DADA      ; Queue anim fn
         TXY             ; Queue index
         PLX             ; ROM index
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $CFF765,X   ; Anim table ptr		=== SNES: $CFF7B5
         INX             ; ROM index +1
         INX             ; ROM index +1
         STA $32C9,Y     ; Set bird's
         SEP #$20        ; 8-bit A
         LDA $CFF765,X   ; Base X / 2			=== SNES: $CFF7B5
         INX             ; ROM index +1
         STA $34CA,Y     ; Set bird's
         LDA $CFF765,X   ; Base Y			=== SNES: $CFF7B5
         INX             ; ROM index +1
         STA $344A,Y     ; Set bird's
         LDA #$01        ; Pans with BG1
         STA $364A,Y     ; Set OBJ flags
         PLB             ; Restore DB
         CPX #$0018      ; Done 6 birds?
         BNE C3DA44      ; Loop if not
         RTS

; Create oscillating birds around skimming airship
C3DA78:  LDX $00         ; ROM index: 0
C3DA7A:  PHX             ; Save ROM index
         JSR C3DADA      ; Queue anim fn
         TXY             ; Queue index
         PLX             ; ROM index
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $CFF77D,X   ; Anim table ptr		=== SNES: $CFF7CD
         INX             ; ROM index +1
         INX             ; ROM index +1
         STA $32C9,Y     ; Set bird's
         SEP #$20        ; 8-bit A
         LDA $CFF77D,X   ; Base X / 2			=== SNES: $CFF7CD
         INX             ; ROM index +1
         STA $34CA,Y     ; Set bird's
         LDA $CFF77D,X   ; Base Y			=== SNES: $CFF7CD
         INX             ; ROM index +1
         STA $344A,Y     ; Set bird's
         PLB             ; Restore DB
         CPX #$0018      ; Done 6 birds?
         BNE C3DA7A      ; Loop if not
         RTS

; Create birds above grassfield
C3DAA9:  LDX $00         ; ROM index: 0
C3DAAB:  PHX             ; Save ROM index
         JSR C3DADA      ; Queue anim fn
         TXY             ; Queue index
         PLX             ; ROM index
         PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         REP #$20        ; 16-bit A
         LDA $CFF795,X   ; Anim table ptr		=== SNES: $CFF7E5
         INX             ; ROM index +1
         INX             ; ROM index +1
         STA $32C9,Y     ; Set bird's
         SEP #$20        ; 8-bit A
         LDA $CFF795,X   ; Base X / 2			=== SNES: $CFF7E5
         INX             ; ROM index +1
         STA $34CA,Y     ; Set bird's
         LDA $CFF795,X   ; Base Y			=== SNES: $CFF7E5
         INX             ; ROM index +1
         STA $344A,Y     ; Set bird's
         PLB             ; Restore DB
         CPX #$0018      ; Done 6 birds?
         BNE C3DAAB      ; Loop if not
         RTS

; Queue oscillating bird
C3DADA:  LDA #$02        ; Min slot: 16
         LDY #C3DAE3     ; C3/DAE3
         JSR C311DE      ; Queue anim fn
         RTS

; Animate oscillating bird
C3DAE3:  TAX             ; Index mode
         JMP (C3DAE7,X)  ; Handle mode

; Jump table for the above
C3DAE7:  dw C3DAEB       ; Initialize data
         dw C3DB02       ; Sustain sprite

; Mode 0: Initialize data
C3DAEB:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         STZ $334A,X     ; X-Mod index HB
         LDA.L C3DAE3,X  ; X-Mod index LB
         STA $3349,X     ; Set bird's
         LDA #$CF        ; Bank: CF
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3DB02:  LDX $2D         ; Queue index
         JSR C3DB0F      ; Init X position
         INC $3349,X     ; X-Mod index +1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Update bird's back-and-forth motion (range: -8 to +7)
C3DB0F:  REP #$20        ; 16-bit A
         LDA $3349,X     ; X-Mod index
         JSR C3EDC6      ; Fract X mod
         STA $EB         ; Set original
         STA $E0         ; Set current
         LDA $E0         ; Shift right?
         BPL C3DB23      ; Branch if so
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
C3DB23:  STA $E0         ; Save changes
         LDA $EB         ; Shift right?
         BPL C3DB32      ; Branch if so
         JSR C3DBAC      ; Modifier / 16
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
         BRA C3DB35      ; Skip a line
C3DB32:  JSR C3DBAC      ; Modifier / 16
C3DB35:  LDX $2D         ; Queue index
         CLC             ; Prepare ADC
         ADC $34C9,X     ; Add base X/2
         STA $33C9,X     ; Init bird's X
         SEP #$20        ; 8-bit A
         RTS

; Animate skimming airship
C3DB41:  TAX             ; Index mode
         JMP (C3DB45,X)  ; Handle mode

; Jump table
C3DB45:  dw C3DB49       ; Initialize data
         dw C3DB61       ; Sustain sprite

; Mode 0: Initialize data
C3DB49:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         STZ $334A,X     ; Anim timer HB
         STZ $3349,X     ; Anim timer LB
         LDA #$78        ; X: 120
         STA $33CA,X     ; Set sprite's
         LDA #$20        ; Base Y/2: 32
         STA $354A,X     ; Set sprite's
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3DB61:  LDX $2D         ; Queue index
         JSR C3DB7A      ; Init Y position
         LDX $2D         ; Queue index
         INC $3349,X     ; Anim timer +1
         LDA $3349,X     ; Anim timer
         CMP #$38        ; Within 56-255?
         BCS C3DB75      ; Branch if so
         JSR C3DBB3      ; Create spray
C3DB75:  JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Update airship's up-and-down motion (range: -8 to +7)
C3DB7A:  REP #$20        ; 16-bit A
         LDA $3349,X     ; Anim timer
         JSR C3EDCA      ; Fract Y mod
         STA $EB         ; Set original
         STA $E0         ; Set current
         LDA $E0         ; Shift down?
         BPL C3DB8E      ; Branch if so
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
C3DB8E:  STA $E0         ; Save changes
         LDA $EB         ; Shift down?
         BPL C3DB9D      ; Branch if so
         JSR C3DBAC      ; Modifier / 16
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
         BRA C3DBA0      ; Skip a line
C3DB9D:  JSR C3DBAC      ; Modifier / 16
C3DBA0:  LDX $2D         ; Queue index
         CLC             ; Prepare ADC
         ADC $3549,X     ; Add base Y
         STA $3449,X     ; Init ship's Y
         SEP #$20        ; 8-bit A
         RTS

; Divide sprite's position modifier by 16
C3DBAC:  LDA $E0         ; Y modifier
         LSR A           ; ÷2
         LSR A           ; ÷4
         LSR A           ; ÷8
         LSR A           ; ÷16
         RTS

; Create water spray
C3DBB3:  LDA $23         ; NMI count
         AND #$03        ; Now 0-3
         BNE C3DBF3      ; Exit if 1-3
         PHB             ; Save DB
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         JSR C3D7B8      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$8CFB      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         LDA #$0100      ; H-Spd: +1 px
         STA $7E34C9,X   ; Set sprite's
         LDA #$FF80      ; V-Spd: -0.5 px
         STA $7E3549,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$18        ; Frames: 24
         STA $7E3349,X   ; Set hide delay
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$7E        ; X: 126
         STA $7E33CA,X   ; Set sprite's
         LDA #$7C        ; Y: 124
         STA $7E344A,X   ; Set sprite's
         PLB             ; Restore DB
C3DBF3:  RTS

; Animate swooping bird
C3DBF4:  TAX             ; Index mode
         JMP (C3DBF8,X)  ; Handle mode

; Jump table for the above
C3DBF8:  dw C3DBFC       ; Initialize sprite
         dw C3DC23       ; Sustain sprite

; Mode 0: Initialize sprite
C3DBFC:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$CF        ; Anim ptr HB
         STA $35CA,X     ; Set sprite's
         REP #$20        ; 16-bit A
         LDA #$F722      ; Anim ptr LBs			=== SNES: CF/F772
         STA $32C9,X     ; Set sprite's
         LDA #$0010      ; Pos index: 16
         STA $3349,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$00        ; Base X HB: 0
         STA $34CA,X     ; Set sprite's
         LDA #$00        ; Base Y HB: 0
         STA $354A,X     ; Set sprite's
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3DC23:  LDX $2D         ; Queue index
         LDA $33CA,X     ; X position
         CMP #$08        ; Under 8?
         BCS C3DC2E      ; Display if not
         CLC             ; Set to dequeue
         RTS

; Fork: Set X position
C3DC2E:  REP #$20        ; 16-bit A
         LDA $3349,X     ; Position index
         JSR C3EDC6      ; Fractional X
         STA $EB         ; ...
         STA $E0         ; ...
         LDA $E0         ; ...
         BPL C3DC42      ; ...
         EOR #$FFFF      ; ...
         INC A           ; ...
C3DC42:  STA $E0         ; ...
         LDA $EB         ; ...
         BPL C3DC51      ; ...
         LDA $E0         ; ...
         ASL A           ; ...
         EOR #$FFFF      ; ...
         INC A           ; ...
         BRA C3DC54      ; ...
C3DC51:  LDA $E0         ; ...
         ASL A           ; Double it
C3DC54:  LDX $2D         ; Queue index
         CLC             ; Prepare ADC
         ADC $34C9,X     ; Add base X
         STA $33C9,X     ; Set bird's X

; Fork: Set Y position
C3DC5D:  LDA $3349,X     ; Position index
         JSR C3EDCA      ; Fractional Y
         STA $EB         ; ...
         STA $E0         ; ...
         LDA $E0         ; ...
         BPL C3DC6F      ; ...
         EOR #$FFFF      ; ...
         INC A           ; ...
C3DC6F:  STA $E0         ; ...
         LDA $EB         ; ...
         BPL C3DC7D      ; ...
         LDA $E0         ; ...
         EOR #$FFFF      ; ...
         INC A           ; ...
         BRA C3DC7F      ; ...
C3DC7D:  LDA $E0         ; ...
C3DC7F:  LDX $2D         ; Queue index
         CLC             ; Prepare ADC
         ADC $3549,X     ; Add base Y
         STA $3449,X     ; Set bird's Y
         INC $3349,X     ; Pos index +1
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; 14: Start frontview airship scene
C3DC92:  JSL $D4CED7     ; Init registers
         JSR C3D50E      ; Color math: BG1
         JSL C3E4D8      ; Upload GFX, map
         JSR C3D9EC      ; Get sky; init M7
         JSR C3E337      ; Queue gradient
         JSR C3E31A      ; HDMA: Color math
         JSR C3D6C3      ; Load OBJ colors
         LDY #$0028      ; Y: 40
         STY $3B         ; Set BG2 Y-Pos
         LDY #$FFCD      ; Mod index: 205
         STY $C3         ; Set matrices'
         LDY #$030B      ; Vertical angle
         STY $C7         ; Set for field
         LDY #$F000      ; Base divisor
         STY $C5         ; Set matrices'
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         JSR C3E0F7      ; Load BG1 colors
         JSR C3DAA9      ; Create birds
         JSR C3DF60      ; Queue airship
         REP #$20        ; 16-bit A
         LDA #$8C15      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set airship's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$78        ; X: 120
         STA $7E33CA,X   ; Set airship's
         LDA #$58        ; Base Y: 88
         STA $7E354A,X   ; Set airship's
         LDY #$8B29      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue field anim
         JSR C3E920      ; Build text OAM
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         LDA #$02        ; Min slot: 16
         LDY #C3E7FC     ; C3/E7FC
         JSR C311DE      ; Queue credits
         LDA #$03        ; Min slot: 24
         LDY #C3DA2B     ; C3/DA2B
         JSR C311DE      ; Set to pan sky
         JSR C3E224      ; Queue M7 handler
         INC $26         ; Next: Late flock
         LDY #$04B0      ; Frames: 1200
         STY $20         ; Set flock delay
         JMP C3D5DE      ; Queue fade-in

; Queue bird from late flock
C3DD15:  LDA #$02        ; Min slot: 16
         LDY #C3DD68     ; C3/DD68
         JSR C311DE      ; Queue anim fn
         RTS

; 15: Show late bird flock
C3DD1E:  LDY $20         ; Delay expired?
         BNE C3DD67      ; Exit if not
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Fade-out
         LDY #$0708      ; Frames: 1800
         STY $20         ; Set fade delay
         JSR C3DD15      ; Queue bird 1
         LDA #$00        ; X: 0
         STA $7E33CA,X   ; Set for bird 1
         LDA #$50        ; Y: 80
         STA $7E344A,X   ; Set for bird 1
         JSR C3DD15      ; Queue bird 2
         LDA #$18        ; X: 24
         STA $7E33CA,X   ; Set for bird 2
         LDA #$40        ; Y: 64
         STA $7E344A,X   ; Set for bird 2
         JSR C3DD15      ; Queue bird 3
         LDA #$40        ; X: 64
         STA $7E33CA,X   ; Set for bird 3
         LDA #$68        ; Y: 104
         STA $7E344A,X   ; Set for bird 3
         JSR C3DD15      ; Queue bird 4
         LDA #$10        ; X: 16
         STA $7E33CA,X   ; Set for bird 4
         LDA #$48        ; Y: 72
         STA $7E344A,X   ; Set for bird 4
C3DD67:  RTS

; Animate bird from late flock
C3DD68:  TAX             ; Index mode
         JMP (C3DD6C,X)  ; Handle mode

; Jump table for the above
C3DD6C:  dw C3DD7E       ; Initialize data
         dw C3DD9D       ; Unused
         dw C3DD9D       ; Head E after delay
         dw C3DD9D       ; Head SE after delay
         dw C3DD9D       ; Head SSE after delay
         dw C3DD9D       ; Head SSW after delay
         dw C3DD9D       ; Head SW after delay
         dw C3DD9D       ; Head SW x2 after delay
         dw C3DDB1       ; Delete if at left edge

; Mode 0: Initialize data
C3DD7E:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$F6FF      ; Anim table ptr		=== SNES: CF/F74F
         STA $32C9,X     ; Set bird's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $35CA,X     ; Set ptr HB
         STZ $35C9,X     ; Course: NE
         JSR C3DDC1      ; Define path
         LDX $2D         ; Queue index
         JSR C31271      ; Set pose timer

; Modes 1-7: Alter course
C3DD9D:  LDX $2D         ; Queue index
         LDY $3349,X     ; Mode expired?
         BNE C3DDA9      ; Branch if not
         JSR C3DDC1      ; Alter path
         LDX $2D         ; Queue index
C3DDA9:  JSR C3DF69      ; Mode timer -1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Mode 8: Delete if set to wrap horizontally
C3DDB1:  JSR C3EE10      ; Scroll & OAM
         LDX $2D         ; Queue index
         LDA $33CA,X     ; Bird's X
         CMP #$01        ; Zero?
         BCS C3DDBF      ; Maintain if not
         CLC             ; Set to dequeue
         RTS             ; Exit
C3DDBF:  SEC             ; Set to requeue
         RTS

; Alter course of bird from late flock
C3DDC1:  LDY $2D         ; Queue index
         TYX             ; Put it in X
         TDC             ; Clear A
         LDA $35C9,Y     ; Path index
         INC $35C9,X     ; Path Index +1
         INC $3649,X     ; Mode +1
         ASL A           ; Index x2
         ASL A           ; Index x4
         ASL A           ; Index x8
         REP #$20        ; 16-bit A
         TAX             ; Index it
         LDA.L C3DDEC,X  ; H-Speed
         STA $34C9,Y     ; Set bird's
         LDA.L C3DDEC+2,X; V-Speed
         STA $3549,Y     ; Set bird's
         LDA.L C3DDEC+4,X; Path timer
         STA $3349,Y     ; Set bird's
         SEP #$20        ; 8-bit A
         RTS

; Late bird flock's course
C3DDEC:  dw $0020        ; H-Speed: +0.125 px
         dw $FFF0        ; V-Speed: -0.0625 px
         dw $0384        ; Frames: 900
         dw $0000        ; ...
         dw $0020        ; H-Speed: +0.125 px
         dw $0000        ; V-Speed: 0
         dw $003C        ; Frames: 60
         dw $0000        ; ...
         dw $0020        ; H-Speed: +0.125 px
         dw $0020        ; V-Speed: +0.125 px
         dw $003C        ; Frames: 60
         dw $0000        ; ...
         dw $0010        ; H-Speed: +0.0625 px
         dw $0040        ; V-Speed: +0.25 px
         dw $003C        ; Frames: 60
         dw $0000        ; ...
         dw $FFE0        ; H-Speed: -0.125 px
         dw $0040        ; V-Speed: +0.25 px
         dw $003C        ; Frames: 60
         dw $0000        ; ...
         dw $FFC0        ; H-Speed: -0.25 px
         dw $0040        ; V-Speed: +0.25 px
         dw $00B4        ; Frames: 180
         dw $0000        ; ...
         dw $FF80        ; H-Speed: -0.5 px
         dw $0080        ; V-Speed: +0.5 px
         dw $00B4        ; Frames: 180
         dw $0000        ; ...

; 18: Start aerial-view plains scene
C3DE24:  JSL $D4CED7     ; Init registers
         JSR C3D50E      ; Color math: BG1
         JSL C3E4D8      ; Upload GFX, map
         JSR C3E376      ; Reset M7 vars
         JSL $D4CB8F     ; HDMA: Matrices
         LDY #$1800      ; Base divisor
         STY $C5         ; Set matrices'
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         JSR C3E0E0      ; Make text black
         JSR C3E0F7      ; Load BG1 colors
         LDY #$8AEA      ; Anim ptr LBs			=== SNES address differs
         LDA #$C2        ; Anim ptr HB
         JSR C3E1A9      ; Queue field anim
         JSR C3E936      ; Build text OAM
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         LDA #$02        ; Min slot: 16
         LDY #C3E84A     ; C3/E84A
         JSR C311DE      ; Queue credits
         JSR C3E224      ; Queue M7 handler
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Fade-out
         LDY #$0E10      ; Frames: 3600
         STY $20         ; Set fade delay
         JMP C3D5DE      ; Queue fade-in

; 1C: Start rearview airship scene
C3DE6D:  JSL $D4CED7     ; Init registers
         JSL C3E4D8      ; Upload GFX, map
         JSR C3E0C8      ; Upload balloon
         JSR C3D9EC      ; Get sky; init M7
         JSR C3E337      ; Queue gradient
         JSR C3E31A      ; HDMA: Color math
         LDY #$0100      ; Base divisor
         STY $C5         ; Set matrices'
         LDY #$02DC      ; Vertical angle
         STY $C7         ; Set for field
         JSR C3ED22      ; Make matrix tbl
         JSR C3E2BF      ; Useless...			%%%
         LDY #$0010      ; Y: 16
         STY $3B         ; Set BG2 Y-Pos
         JSR C3E0E0      ; Make text black
         JSR C3D6C3      ; Load OBJ colors
         JSR C3E0F7      ; Load BG1 colors
         JSR C3E941      ; Build text OAM
         LDY $00         ; Scene timer: 0
         STY $CF         ; Set for text
         LDA #$02        ; Min slot: 16
         LDY #C3E898     ; C3/E898
         JSR C311DE      ; Queue credits
         LDA #$00        ; Min slot: 0
         LDY #C3DF1E     ; C3/DF1E
         JSR C311DE      ; Queue BG scroll
         JSR C3DF36      ; Queue SW rotor
         LDA #$14        ; Y: 20
         STA $7E354A,X   ; Set SW rotor's
         LDA #$44        ; X: 68
         STA $7E33CA,X   ; Set SW rotor's
         JSR C3DF4B      ; Queue SE rotor
         LDA #$14        ; Y: 20
         STA $7E354A,X   ; Set SE rotor's
         LDA #$AC        ; X: 172
         STA $7E33CA,X   ; Set SE rotor's
         JSR C3DF36      ; Queue NW rotor
         LDA #$E8        ; Y: 232
         STA $7E354A,X   ; Set NW rotor's
         LDA #$60        ; X: 96
         STA $7E33CA,X   ; Set NW rotor's
         JSR C3DF4B      ; Queue NE rotor
         LDA #$E8        ; Y: 232
         STA $7E354A,X   ; Set NE rotor's
         LDA #$90        ; X: 144
         STA $7E33CA,X   ; Set NE rotor's
         JSR C3DF60      ; Queue airship
         REP #$20        ; 16-bit A
         LDA #$8C50      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set airship's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$48        ; X: 72
         STA $7E33CA,X   ; Set airship's
         LDA #$F8        ; Y: 248
         STA $7E354A,X   ; Set airship's
         LDA #$03        ; C3/D81B
         STA $26         ; Next: Fade-out
         LDY #$08AC      ; Frames: 2220
         STY $20         ; Set fade delay
         JMP C3D5DE      ; Queue fade-in

; Scroll field and sky for rearview airship scene
C3DF1E:  LDA $23         ; NMI count
         AND #$7F        ; 0 or 128?
         BNE C3DF26      ; Branch if not
         INC $3B         ; Shift sky up
C3DF26:  LDA $23         ; NMI count
         AND #$01        ; Odd value?
         BNE C3DF34      ; Exit if so
         REP #$20        ; 16-bit A
         DEC $B9         ; Center Y -1
         DEC $37         ; Move field down
         SEP #$20        ; 8-bit A
C3DF34:  SEC             ; Set to requeue
         RTS

; Queue NW or SW airship rotor
C3DF36:  JSR C3DF60      ; Queue anim fn
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         REP #$20        ; 16-bit A
         LDA #$8D2E      ; Anim ptr LBs			=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Queue NE or SE airship rotor
C3DF4B:  JSR C3DF60      ; Queue anim fn
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         REP #$20        ; 16-bit A
         LDA #$8D81      ; Anim ptr LBs			=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         RTS

; Queue frontview or rearview airship or rotor
C3DF60:  LDA #$02        ; Min slot: 16
         LDY #C3DF7C     ; C3/DF7C
         JSR C311DE      ; Queue OAM fn
         RTS

; Decrease sprite's animation mode timer
C3DF69:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         DEC $3349,X     ; Timer -1
         SEP #$20        ; 8-bit A
         RTS

; Define sprite's animation mode timer (unused)
C3DF73:  REP #$20        ; 16-bit A
         TYA             ; Get timer
         STA $3349,X     ; Set timer
         SEP #$20        ; 8-bit A
         RTS

; Animate frontview or rearview airship or rotor
C3DF7C:  TAX             ; Index mode
         JMP (C3DF80,X)  ; Handle mode

; Jump table
C3DF80:  dw C3DF84       ; Initialize timers
         dw C3DF8F       ; Sustain sprite

; Mode 0: Initialize timers
C3DF84:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         STZ $3349,X     ; Anim timer: 0
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3DF8F:  LDX $2D         ; Queue index
         JSR C3DB7A      ; Set altitute
         INC $3349,X     ; Anim timer +1
         JSR C3128C      ; Define OAM
         SEC             ; Set to requeue
         RTS

; Load colors for blue sky and non-sprite airships
C3DF9C:  LDA #$C2        ; Source HB
         LDY #$3049      ; To BG pal 0
         LDX #$9594      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Load fill color
         LDA #$C2        ; Source HB
         LDY #$3069      ; To BG pal 1
         LDX #$9594      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; Load the rest
         RTS

; 20: Start final airship scene
C3DFB3:  JSL $D4CED7     ; Init registers
         JSR C3D50E      ; Color math: BG1
         LDA #$80        ; Map wraps: No
         STA $211A       ; Set M7 settings
         JSR C3E56F      ; Upload GFX, map
         JSR C3E376      ; Reset M7 vars
         JSL $D4CE55     ; HDMA: MS desig
         LDA #$C2        ; Source HB
         LDY #$31C9      ; To OBJ pal 4
         LDX #$974C      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; No text...
         LDA #$C2        ; Source HB
         LDY #$31E9      ; To OBJ pal 5
         LDX #$9744      ; Source LBs			=== SNES address differs
         JSR C30FF9      ; No text...
         JSR C3E0F7      ; No field...
         JSR C3DF9C      ; Load BG colors
         LDY #$0001      ; Zoom-out: 1
         STY $BB         ; Set matrix A
         STY $C1         ; Set matrix D
         LDY #$0008      ; X: 8
         STY $B7         ; Set center X
         LDY #$0018      ; Y: 24
         STY $B9         ; Set center Y
         LDY #$FFD8      ; X: -40
         STY $35         ; Set BG1 X-Pos
         LDY #$FFD0      ; Y: -48
         STY $37         ; Set BG1 Y-Pos
         LDA #$00        ; Min slot: 0
         LDY #C3E0A6     ; C3/E0A6
         JSR C311DE      ; Queue zoom-out
         INC $26         ; Next: C3/E01A
         LDY #$0096      ; Frames: 150
         STY $20         ; Set fade delay
         LDA #$00        ; Min slot: 0
         LDY #C3E02C     ; C3/E02C
         JSR C311DE      ; Queue rotor fn
         JMP C3D5DE      ; Queue fade-in

; 21: Fade final airship
C3E01A:  LDY $20         ; Delay expired?
         BNE C3E02B      ; Exit if not
         STZ $26         ; Next: Fade-out
         LDY #$0078      ; Frames: 120
         STY $20         ; Set fade timer
         JSR C3F0A5      ; Fade BG pal 1+2
         JSR C3F17B      ; Fade BG pal 0
C3E02B:  RTS

; Animate final airship's rotors
C3E02C:  LDA $23         ; NMI count
         AND #$01        ; Even value?
         BEQ C3E043      ; Branch if so
         LDA #$51        ; Tile: 81
         STA $7E9849     ; Set L-Rotor's
         LDA #$4F        ; Tile: 79
         STA $7E984A     ; Set R-Rotor's
         JSR C3E054      ; Queue upload
         SEC             ; Set to requeue
         RTS             ; Exit
C3E043:  LDA #$59        ; Tile: 89
         STA $7E9849     ; Set L-Rotor's
         LDA #$5A        ; Tile: 90
         STA $7E984A     ; Set R-Rotor's
         JSR C3E054      ; Queue upload
         SEC             ; Set to requeue
         RTS

; Set to refresh final airship's rotors
C3E054:  LDY #$0283      ; L-Rotor adr
         STY $14         ; Set VRAM ptr1
         LDY #$9849      ; 7E/9849
         STY $16         ; Set src1 LBs
         LDY #$0206      ; R-Rotor adr
         STY $1B         ; Set VRAM ptr2
         LDY #$984A      ; 7E/984A
         STY $1D         ; Set src2 LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src1 HB
         STA $1F         ; Set src2 HB
         LDY #$0001      ; Bytes: 1
         STY $12         ; Set src1 size
         STY $19         ; Set src2 size
         RTS

; Animate sideview airship's rotors
C3E076:  LDA $23         ; NMI count
         AND #$01        ; Even value?
         BEQ C3E087      ; Branch if so
         LDA #$58        ; Tile: 88
         STA $7E9849     ; Set rotors'
         JSR C3E092      ; Queue upload
         SEC             ; Set to requeue
         RTS             ; Exit
C3E087:  LDA #$34        ; Tile: 52
         STA $7E9849     ; Set rotors'
         JSR C3E092      ; Queue upload
         SEC             ; Set to requeue
         RTS

; Set to refresh sideview airship's rotors
C3E092:  LDY #$0892      ; $0892
         STY $14         ; Set VRAM ptr
         LDY #$9849      ; 7E/9849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$0001      ; Bytes: 1
         STY $12         ; Set data size
         RTS

; Process queued zoom-out for final airship scene
C3E0A6:  JSR C3E0AB      ; Zoom out
         SEC             ; Set to requeue
         RTS

; Zoom out from final airship
C3E0AB:  LDA $23         ; NMI count
         AND #$07        ; Now 0-7
         BNE C3E0BB      ; Branch if > 0
         LDY $B9         ; M7 center Y
         DEY             ; Subtract 1
         STY $B9         ; Save changes
         LDY $B7         ; M7 center X
         INY             ; Add 1
         STY $B7         ; Save changes
C3E0BB:  REP #$20        ; 16-bit A
         INC $BB         ; Matrix A +1
         INC $BB         ; Matrix A +1
         INC $C1         ; Matrix D +1
         INC $C1         ; Matrix D +1
         SEP #$20        ; 8-bit A
         RTS

; Upload rearview airship's balloon graphics
C3E0C8:  LDY #$D7BA      ; 7E/D7BA
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0580      ; Bytes: 1408
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$6C00      ; VRAM pointer
         JMP C3ED09      ; Upload data

; Initialize credits' colors to black for fade-in
C3E0E0:  LDA #$C3        ; Src HB
         LDY #$31C9      ; To OBJ pal 4
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; Do big font
         LDA #$C3        ; Src HB
         LDY #$31E9      ; To OBJ pal 5
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; Do small font
         RTS

; Load BG1 palettes for credits scenes
C3E0F7:  LDA #$C2        ; Src HB
         LDY #$3069      ; To BG pal 1
         LDX #$95B4      ; Src LBs			=== SNES address differs
         JSR C30FF9      ; C3/DFAF...
         LDA #$C2        ; Src HB
         LDY #$3089      ; To BG pal 2
         LDX #$95D4      ; Src LBs			=== SNES address differs
         JSR C30FF9      ; Do sea
         LDA #$C2        ; Src HB
         LDY #$30A9      ; To BG pal 3
         LDX #$95F4      ; Src LBs			=== SNES address differs
         JSR C30FF9      ; Do clouds
         LDA #$C2        ; Src HB
         LDY #$30C9      ; To BG pal 4
         LDX #$9614      ; Src LBs			=== SNES address differs
         JSR C30FF9      ; Do trees
         LDA #$C2        ; Src HB
         LDY #$3109      ; To BG pal 6
         LDX #$9634      ; Src LBs			=== SNES address differs
         JSR C30FF9      ; Do lake
         LDA #$C2        ; Src HB
         LDY #$3129      ; To BG pal 7
         LDX #$9654      ; Src LBs			=== SNES address differs
         JSR C30FF9      ; Do grass
         RTS

; Scroll actor's pseudonym down
C3E13A:  LDY $CF         ; Scroll timer
         CPY $64         ; At endpoint?
         BEQ C3E14E      ; Dequeue if so
         LDA $23         ; NMI count
         AND #$03        ; Now 0-3
         BNE C3E14C      ; Exit if 1-3
         REP #$20        ; 16-bit A
         DEC $3F         ; BG3 camera up
         SEP #$20        ; 8-bit A
C3E14C:  SEC             ; Set to requeue
         RTS             ; Exit
C3E14E:  CLC             ; Set to dequeue
         RTS

; Process queued field fade-in
C3E150:  TAX             ; Index mode
         JMP (C3E154,X)  ; Handle mode

; Jump table
C3E154:  dw C3E158       ; Initialize brightness
         dw C3E167       ; Increase brightness

; Mode 0: Initialize brightness
C3E158:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$01        ; BRT: 1 and ON
         STA $344A,X     ; Set next BRT
         LDA #$0F        ; Frames: 15
         STA $3349,X     ; Set timer

; Mode 1: Increase brightness
C3E167:  LDX $2D         ; Queue index
         LDA $3349,X     ; Timer expired?
         BEQ C3E17B      ; Finalize if so
         LDA $344A,X     ; Next brightness
         STA $44         ; Set as current
         INC $344A,X     ; Next BRT +1
         DEC $3349,X     ; Timer -1
         SEC             ; Set to requeue
         RTS             ; Exit
C3E17B:  LDA #$0F        ; BRT: 15 and ON
         STA $44         ; Set brightness
         CLC             ; Set to dequeue
         RTS

; Process queued field fade-out
C3E181:  TAX             ; Index mode
         JMP (C3E185,X)  ; Handle mode

; Jump table
C3E185:  dw C3E189       ; Initialize brightness
         dw C3E193       ; Decrease brightness

; Mode 0: Initialize brightness
C3E189:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$0F        ; BRT: 15 and ON
         STA $33CA,X     ; Set next BRT

; Mode 1: Decrease brightness
C3E193:  LDY $20         ; Timer expired?
         BEQ C3E1A3      ; Finalize if so
         LDX $2D         ; Queue index
         LDA $33CA,X     ; Next brightness
         STA $44         ; Set as current
         DEC $33CA,X     ; Next BRT -1
         SEC             ; Set to requeue
         RTS             ; Exit
C3E1A3:  LDA #$80        ; BRT: 0 and OFF
         STA $44         ; Set brightness
         CLC             ; Set to dequeue
         RTS

; Queue Mode 7 animation script loading
C3E1A9:  PHA             ; Save ptr HB
         PHY             ; Save ptr LBs
         LDA #$01        ; Min slot: 8
         LDY #C3E1C3     ; C3/E1C3
         JSR C311DE      ; Queue anim fn
         REP #$20        ; 16-bit A
         PLY             ; Anim ptr LBs
         TYA             ; Put in A
         STA $7E32C9,X   ; Put in queue
         SEP #$20        ; 8-bit A
         PLA             ; Anim ptr HB
         STA $7E35CA,X   ; Put in queue
         RTS

; Load parameters for Mode 7 animation
C3E1C3:  TAX             ; Index mode
         JMP (C3E1C7,X)  ; Handle mode

; Jump table for the above
C3E1C7:  dw C3E1CB       ; Initialize timer
         dw C3E1D3       ; Load animation flags

; Mode 0: Initialize sequence timer
C3E1CB:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set anim timer

; Mode 1: Load animation flags
C3E1D3:  LDX $2D         ; Queue index
         JSR C31292      ; Anim timer -1
         TDC             ; Clear A
         LDA $36C9,X     ; Anim index
         TAY             ; Index it
         REP #$20        ; 16-bit A
         LDA [$EB],Y     ; Anim flags
         STA $04         ; Set as current
         SEP #$20        ; 8-bit A
         SEC             ; Set to requeue
         RTS

; Refresh Mode 7 registers (NMI)
C3E1E7:  LDA $BB         ; Matrix A LB
         STA $211B       ; To register
         LDA $BC         ; Matrix A HB
         STA $211B       ; To register
         LDA $BD         ; Matrix B LB
         STA $211C       ; To register
         LDA $BE         ; Matrix B HB
         STA $211C       ; To register
         LDA $BF         ; Matrix C LB
         STA $211D       ; To register
         LDA $C0         ; Matrix C HB
         STA $211D       ; To register
         LDA $C1         ; Matrix D LB
         STA $211E       ; To register
         LDA $C2         ; Matrix D HB
         STA $211E       ; To register
         LDA $B7         ; Center X LB
         STA $211F       ; To register
         LDA $B8         ; Center X HB
         STA $211F       ; To register
         LDA $B9         ; Center Y LB
         STA $2120       ; To register
         LDA $BA         ; Center Y HB
         STA $2120       ; To register
         RTS

; Queue Mode 7 animation script decoding
C3E224:  LDA #$00        ; Min slot: 0
         LDY #C3E22D     ; C3/E22D
         JSR C311DE      ; Queue anim fn
         RTS

; Decode parameters for Mode 7 animation
C3E22D:  LDA $04         ; Anim flags
         BIT #$10        ; Tilt right?
         BEQ C3E23B      ; Skip if not
         REP #$20        ; 16-bit A
         INC $C3         ; Mod index +1
         SEP #$20        ; 8-bit A
         INC $59         ; No use...

; Fork: Rotate counterclockwise
C3E23B:  LDA $04         ; Anim flags
         BIT #$20        ; Tilt left?
         BEQ C3E249      ; Skip if not
         REP #$20        ; 16-bit A
         DEC $C3         ; Mod index -1
         SEP #$20        ; 8-bit A
         DEC $59         ; No use...

; Fork: Rotate forward
C3E249:  LDA $04         ; Anim flags
         BIT #$40        ; Tilt up?
         BEQ C3E255      ; Skip if not
         REP #$20        ; 16-bit A
         INC $C7         ; Matrix mod +1
         SEP #$20        ; 8-bit A

; Fork: Rotate backward
C3E255:  LDA $05         ; Anim flags
         BIT #$40        ; Tilt down?
         BEQ C3E261      ; Skip if not
         REP #$20        ; 16-bit A
         DEC $C7         ; Matrix mod -1
         SEP #$20        ; 8-bit A

; Fork: Zoom in
C3E261:  LDA $04         ; Anim flags
         BIT #$80        ; Inc divisor?
         BEQ C3E269      ; Skip if not
         INC $C6         ; Divisor +1

; Fork: Zoom out
C3E269:  LDA $05         ; Anim flags
         BIT #$80        ; Dec divisor?
         BEQ C3E271      ; Skip if not
         DEC $C6         ; Divisor -1

; Fork: Scroll southward
C3E271:  LDA $05         ; Anim flags
         BIT #$08        ; Scroll down?
         BEQ C3E27F      ; Skip if not
         REP #$20        ; 16-bit A
         DEC $B9         ; Center Y -1
         DEC $37         ; BG1 Y-Pos -1
         SEP #$20        ; 8-bit A

; Fork: Scroll northward
C3E27F:  LDA $05         ; Anim flags
         BIT #$04        ; Scroll up?
         BEQ C3E28D      ; Skip if not
         REP #$20        ; 16-bit A
         INC $B9         ; Center Y +1
         INC $37         ; BG1 Y-Pos +1
         SEP #$20        ; 8-bit A

; Fork: Scroll eastward
C3E28D:  LDA $05         ; Anim flags
         BIT #$02        ; Scroll right?
         BEQ C3E29B      ; Skip if not
         REP #$20        ; 16-bit A
         DEC $B7         ; Center X -1
         DEC $35         ; BG1 X-Pos -1
         SEP #$20        ; 8-bit A

; Fork: Scroll westward
C3E29B:  LDA $05         ; Anim flags
         BIT #$01        ; Scroll left?
         BEQ C3E2A9      ; Skip if not
         REP #$20        ; 16-bit A
         INC $B7         ; Center X +1
         INC $35         ; BG1 X-Pos +1
         SEP #$20        ; 8-bit A

; Fork: Build Mode 7 matrix tables
C3E2A9:  JSR C3E2E3      ; Cap center X/Y
         REP #$20        ; 16-bit A
         LDA $04         ; Anim flags
         AND #$F0FF      ; Only scrolling?
         SEP #$20        ; 8-bit A
         BEQ C3E2BD      ; Exit if so
         JSR C3ED22      ; Build tables
         JSR C3E2BF      ; Useless...			%%%
C3E2BD:  SEC             ; Set to requeue
         RTS

; Copy matrix data for first scanline to global variables (useless)	%%%
C3E2BF:  LDY $07C2       ; Mtx A overscan
         STY $07C4       ; Never read...
         LDY $0984       ; Mtx B overscan
         STY $0986       ; Never read...
         LDY $0B46       ; Mtx C overscan
         STY $0B48       ; Never read...
         LDY $0602       ; Mtx A, line 1
         STY $BB         ; Set global A
         STY $C1         ; Set global D
         LDY $07C4       ; Mtx B, line 1
         STY $BD         ; Set global B
         LDY $0986       ; Mtx C, line 1
         STY $BF         ; Set global C
         RTS

; Keep Mode 7 center X and Y within boundaries
C3E2E3:  REP #$20        ; 16-bit A
         LDA $B7         ; Center X
         AND #$1FFF      ; Clear excess
         STA $B7         ; Save changes
         LDA $B9         ; Center Y
         AND #$1FFF      ; Clear excess
         STA $B9         ; Save changes
         SEP #$20        ; 8-bit A
         RTS

; Configure Mode 7 not to apply to cloudy sky
C3E2F6:  JSL $D4CB8F     ; HDMA: Matrices
         STZ $4310       ; 1Rx1B to PPU
         LDA #$05        ; $2105
         STA $4311       ; To BG mode
         LDY #C3E315     ; C3/E315
         STY $4312       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4314       ; Set src HB
         STA $4317       ; Set indir HB
         LDA #$02        ; Channel: 1
         TSB $43         ; Queue HDMA-1
         RTS

; BG mode and tile size per scanline
C3E315:  db $47,$01      ; Mode 1, 8x8 tiles
         db $01,$07      ; Mode 7
         db $00          ; End

; Set color addition and math for field and for cloudy sky
C3E31A:  LDA #$01        ; 2Rx1B to PPU
         STA $4330       ; Set DMA mode
         LDA #$30        ; $2130, $2131
         STA $4331       ; To color regs
         LDY #C3E352     ; C3/E352
         STY $4332       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4334       ; Set src HB
         STA $4337       ; Set indir HB
         LDA #$08        ; Channel: 3
         TSB $43         ; Queue HDMA-3
         RTS

; Queue gradient effect for field under sky
C3E337:  STZ $4320       ; 1Rx1B to PPU
         LDA #$32        ; $2132
         STA $4321       ; To fixed color
         LDY #C3E359     ; C3/E359
         STY $4322       ; Set src LBs
         LDA #$C3        ; Bank: C3
         STA $4324       ; Set src HB
         STA $4327       ; Set indir HB
         LDA #$04        ; Channel: 2
         TSB $43         ; Queue HDMA-2
         RTS

; Color addition and math per scanline
C3E352:  db $47,$80,$41  ; BG1, inside window, half mode
         db $01,$82,$01  ; BG1, inside window, add subscreen
         db $00          ; End

; Gradient table for the above
C3E359:  db $47,$E0      ; RGB: 0
         db $01,$ED      ; RGB: 13
         db $01,$EB      ; RGB: 11
         db $01,$EA      ; RGB: 10
         db $02,$E9      ; RGB: 9
         db $03,$E8      ; RGB: 8
         db $04,$E7      ; RGB: 7
         db $05,$E6      ; RGB: 6
         db $06,$E5      ; RGB: 5
         db $07,$E4      ; RGB: 4
         db $08,$E3      ; RGB: 3
         db $0C,$E2      ; RGB: 2
         db $0F,$E1      ; RGB: 1
         db $1E,$E0      ; RGB: 0
         db $00          ; End














; Reset Mode 7 parameters
C3E376:  LDY #$0100      ; 256
         STY $B7         ; Set center X
         LDY #$0080      ; 128
         STY $B9         ; Set center Y
         STY $35         ; Set BG1 X-Pos
         TDC             ; Clear A
         TAY             ; Clear Y
         STY $37         ; BG1 Y-Pos: 0
         STZ $58         ; No use...
         LDA #$40        ; No use...
         STA $59         ; No use...
         LDY #$0000      ; Vertical angle
         STY $C7         ; Set for BG1
         LDY #$0100      ; Base divisor
         STY $C5         ; Set matrices'
         LDY #$0000      ; Mod index: 0
         STY $C3         ; Set matrices'
         RTS

; Unpack and upload graphics and tilemaps for sideview airship scene
C3E39C:  JSR C3E3C9      ; Upload font GFX
         JSR C3E616      ; Unpack map, GFX
         JSR C3E5D0      ; Pal numbers loc
         JSR C3E4B7      ; Convert M7 GFX A
         JSR C3E3BA      ; Insert tilemap A
         JSR C3E599      ; Upload M7 map A
         JSR C3E5D0      ; Pal numbers loc
         JSR C3E4C7      ; Convert M7 GFX B
         JSR C3E3BA      ; Insert tilemap B
         JMP C3E5B1      ; Upload M7 map B

; Assemble half of tilemap for sideview airship scene
C3E3BA:  JSR C3E5F2      ; Set ptrs loc
         LDX #$FC1A      ; Tiles loc
         STX $F1         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $F3         ; Set src HB
         JMP C3E66B      ; Build map

; Unpack and upload font graphics for credits
C3E3C9:  LDY #$B500      ; Source LBs			=== SNES: BA00
         LDA #$CE        ; Source HB			=== SNES: C4
         JSR C3ECB1      ; Load big font
         JSR C3E3FC      ; Set as 16x16
         LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0C00      ; Bytes: 3072
         STY $EB         ; Set data size
         LDY #$7000      ; VRAM pointer
         JSR C3ECD6      ; Upload font
         LDY #$81C0      ; C4/81C0			=== SNES: C4/87C0
         STY $E7         ; Set src LBs
         LDA #$C4        ; Bank: C4
         STA $E9         ; Set src HB
         LDY #$0200      ; Bytes: 512
         STY $EB         ; Set data size
         LDY #$7E00      ; VRAM pointer
         JMP C3ECD6      ; Do small font




















; Expand large font graphics to 16x16 for credits
C3E3FC:  PHB             ; Save DB
         LDA #$7E        ; Bank: 7E
         PHA             ; Put on stack
         PLB             ; Set DB to 7E
         LDX $00         ; ROM index: 0
         TXY             ; Dst index: 0
C3E404:  PHX             ; Save ROM index
         TDC             ; Clear A
         LDA $C2984C,X   ; Tile index			=== SNES: $C29854
         REP #$20        ; 16-bit A
         ASL A           ; x2
         ASL A           ; x4
         ASL A           ; x8
         ASL A           ; x16
         TAX             ; Index it
         SEP #$20        ; 8-bit A
         LDA #$10        ; Rows: 8
         STA $E0         ; Set counter
C3E417:  LDA $C000,X     ; 8 px, 1 plane
         STA $C400,Y     ; Put in buffer
         INX             ; Src index +1
         INY             ; Dst index +1
         DEC $E0         ; Counter -1
         BNE C3E417      ; Loop till zero

; Fork: Blank right-hand 8x8 tile
C3E423:  TDC             ; Clear A
         TAX             ; Counter: 0
C3E425:  STA $C400,Y     ; Clear a plane
         INY             ; Dst index +1
         INX             ; Counter +1
         CPX #$0010      ; Done 8 rows?
         BNE C3E425      ; Loop if not
         PLX             ; ROM index
         INX             ; ROM index +1
         CPX #$0040      ; Done 64 tiles?
         BNE C3E404      ; Loop if not
         PLB             ; Restore DB
         RTS

; Unpack and upload cloudy sky graphics and tilemap
C3E438:  REP #$20        ; 16-bit A
         LDA $EEB206     ; Source LBs
         TAY             ; Put in Y
         SEP #$20        ; 8-bit A
         LDA $EEB208     ; Source HB
         JSR C3ECB1      ; Unpack graphics
         JSR C3E47D      ; Src: 7E/C000
         LDY #$1A20      ; Bytes: 6688
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$4000      ; VRAM pointer
         JSR C3ED09      ; Upload graphics
         REP #$20        ; 16-bit A
         LDA $EEB209     ; Source LBs
         TAY             ; Put in Y
         SEP #$20        ; 8-bit A
         LDA $EEB20B     ; Source HB
         JSR C3ECB1      ; Unpack tilemap
         LDY #$2000      ; Add: Priority
         STY $ED         ; Set complement
         JSR C3E47D      ; Src: 7E/C000
         LDY #$0400      ; Bytes: 1024
         STY $EB         ; Set data size
         LDY #$5000      ; VRAM pointer
         JMP C3ED09      ; Upload tilemap

; Set source for uploading decompressed data
C3E47D:  LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         RTS

; Unpack and upload graphics and tilemaps for dense clouds
C3E487:  JSR C3E3C9      ; Upload font GFX
         JSR C3E616      ; Unpack map, GFX
         JSR C3E63B      ; Upload sprites
         JSR C3E5D0      ; Pal numbers loc
         JSR C3E4B7      ; Convert M7 GFX A
         JSR C3E4A8      ; Insert tilemap A
         JSR C3E599      ; Upload M7 map A
         JSR C3E5D0      ; Pal numbers loc
         JSR C3E4C7      ; Convert M7 GFX B
         JSR C3E4A8      ; Insert tilemap B
         JMP C3E5B1      ; Upload M7 map B

; Assemble half of tilemap for dense clouds
C3E4A8:  JSR C3E5EB      ; Set ptrs loc
         LDX #$FC1A      ; Tiles loc
         STX $F1         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $F3         ; Set src HB
         JMP C3E66B      ; Build map

; Add 4bpp graphics to Mode 7 map (first 128 tiles)
C3E4B7:  STZ $E4         ; Pal index LB
         STZ $E5         ; Pal index HB
         LDA #$80        ; Tiles: 128
         STA $ED         ; Set counter
         LDX #$9800      ; Source LBs
         LDA #$7F        ; Source HB
         JMP C3E6B4      ; Convert GFX

; Add 4bpp graphics to Mode 7 map (last 128 tiles)
C3E4C7:  LDX #$0080      ; Index: 128
         STX $E4         ; Set pal index
         LDA #$80        ; Tiles: 128
         STA $ED         ; Set counter
         LDX #$A800      ; Source LBs
         LDA #$7F        ; Source HB
         JMP C3E6B4      ; Convert GFX

; Unpack and upload graphics and tilemaps for grassfield scenes
C3E4D8:  JSR C3E3C9      ; Upload font GFX
         JSR C3E5F9      ; Unpack map, GFX
         JSR C3E63B      ; Upload sprites
         JMP C3E4E7      ; Upload M7 map

; Unpack and upload graphics and tilemaps for second-last airship scene
C3E4E4:  JSR C3E5F9      ; Unpack map, GFX
C3E4E7:  JSR C3E5C9      ; Pal numbers loc
         JSR C3E4B7      ; Convert M7 GFX A
         JSR C3E500      ; Insert tilemap A
         JSR C3E599      ; Upload M7 map A
         JSR C3E5C9      ; Pal numbers loc
         JSR C3E4C7      ; Convert M7 GFX B
         JSR C3E500      ; Insert tilemap B
         JSR C3E5B1      ; Upload M7 map B
         RTL

; Assemble half of grassfield tilemap
C3E500:  JSR C3E5DA      ; Set ptrs loc
         LDX #$DD3A      ; Tiles loc
         STX $F1         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $F3         ; Set src HB
         JMP C3E66B      ; Build map

; Unpack and upload graphics and tilemaps for boat scene
C3E50F:  JSR C3E3C9      ; Upload font GFX
         JSR C3E5F9      ; Unpack map, GFX
         JSR C3E63B      ; Upload sprites
         JSR C3E5C9      ; Pal numbers loc
         JSR C3E4B7      ; Convert M7 GFX A
         JSR C3E530      ; Insert tilemap A
         JSR C3E599      ; Upload M7 map A
         JSR C3E5C9      ; Pal numbers loc
         JSR C3E4C7      ; Convert M7 GFX B
         JSR C3E530      ; Insert tilemap B
         JMP C3E5B1      ; Upload M7 map B

; Assemble half of tilemap for sea with boat
C3E530:  JSR C3E5E4      ; Set ptrs loc
         LDX #$2CFA      ; Tiles loc
         STX $F1         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $F3         ; Set src HB
         JMP C3E66B      ; Build map

; Unpack and upload graphics and tilemaps for skimming airship scene
C3E53F:  JSR C3E3C9      ; Upload font GFX
         JSR C3E5F9      ; Unpack map, GFX
         JSR C3E63B      ; Upload sprites
         JSR C3E5C9      ; Pal numbers loc
         JSR C3E4B7      ; Convert M7 GFX A
         JSR C3E560      ; Insert tilemap A
         JSR C3E599      ; Upload M7 map A
         JSR C3E5C9      ; Pal numbers loc
         JSR C3E4C7      ; Convert M7 GFX B
         JSR C3E560      ; Insert tilemap B
         JMP C3E5B1      ; Upload M7 map B

; Assemble half of tilemap for sea without boat
C3E560:  JSR C3E5EB      ; Set ptrs loc
         LDX #$2CFA      ; Tiles loc
         STX $F1         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $F3         ; Set src HB
         JMP C3E66B      ; Build map

; Unpack and upload graphics and tilemaps for final airship scene
C3E56F:  JSR C3E616      ; Unpack map, GFX
         JSR C3E5D0      ; Pal numbers loc
         JSR C3E4B7      ; Convert M7 GFX A
         JSR C3E58A      ; Insert tilemap
         JSR C3E599      ; Upload M7 map A
         JSR C3E5D0      ; Pal numbers loc
         JSR C3E4C7      ; Convert M7 GFX B
         JSR C3E58A      ; Insert tilemap B
         JMP C3E5B1      ; Upload M7 map B

; Assemble half of tilemap for final airship scene
C3E58A:  JSR C3E5DA      ; Set ptrs loc
         LDX #$041A      ; Tiles loc
         STX $F1         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $F3         ; Set src HB
         JMP C3E66B      ; Build map

; Upload upper half of Mode 7 map
C3E599:  LDY #$B800      ; 7F/B800
         STY $E7         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $E9         ; Set src HB
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$4000      ; Bytes: 16384
         STY $EB         ; Set data size
         LDY #$0000      ; VRAM pointer
         JMP C3ED09      ; Upload map

; Upload lower half of Mode 7 map
C3E5B1:  LDY #$B800      ; 7F/B800
         STY $E7         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $E9         ; Set src HB
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$4000      ; Bytes: 16384
         STY $EB         ; Set data size
         LDY #$2000      ; VRAM pointer
         JMP C3ED09      ; Upload map

; Set palette index table location for plains or sea
C3E5C9:  LDX #$F991      ; Ptrs loc LBs			=== SNES: CF/F9E1
         LDA #$CF        ; Ptrs loc HB
         BRA C3E5D5      ; Set pointer

; Set palette index table location for sky scenes
C3E5D0:  LDX #$F919      ; CF/F919			=== SNES: CF/F969
         LDA #$CF        ; Bank: CF
C3E5D5:  STX $91         ; Set loc LBs
         STA $93         ; Set loc HB
         RTS

; Set tilemap pointer table location for final scenes
C3E5DA:  LDX #$FA99      ; CF/FA99			=== SNES: CF/FAE9
         LDA #$CF        ; Bank: CF
C3E5DF:  STX $F7         ; Set loc LBs
         STA $F9         ; Set loc HB
         RTS

; Set tilemap pointer table location for boat scene
C3E5E4:  LDX #$FA79      ; Table loc LBs		=== SNES: CF/FAC9
         LDA #$CF        ; Table loc HB
         BRA C3E5DF      ; Set pointer

; Set tilemap pointer table location for skimming airship and cloud scenes
C3E5EB:  LDX #$FA59      ; Table loc LBs		=== SNES: CF/FAA9
         LDA #$CF        ; Table loc HB
         BRA C3E5DF      ; Set pointer

; Set tilemap pointer table location for sideview airship scene
C3E5F2:  LDX #$FAB9      ; Table loc LBs		=== SNES: CF/FB09
         LDA #$CF        ; Table loc HB
         BRA C3E5DF      ; Set pointer

; Unpack credits scene GFX and maps, move ocean and grassfield GFX
C3E5F9:  JSR C3E633      ; Unpack data
         LDX #$141A      ; 7F/141A
         STX $E7         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $E9         ; Set src HB
         LDY #$9800      ; 7F/9800
         STY $EB         ; Set dst LBs
         LDA #$7F        ; Bank: 7F
         STA $ED         ; Set dst HB
         LDY #$18E0      ; Bytes: 6368
         STY $EF         ; Set data size
         JMP C3E653      ; Move data

; Unpack credits scene GFX and tilemaps, move cloud and BG airship GFX
C3E616:  JSR C3E633      ; Unpack data
         LDX #$ED3A      ; 7E/ED3A
         STX $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$9800      ; 7F/9800
         STY $EB         ; Set dst LBs
         LDA #$7F        ; Bank: 7F
         STA $ED         ; Set dst HB
         LDY #$0EE0      ; Bytes: 3808
         STY $EF         ; Set data size
         JMP C3E653      ; Move data

; Unpack non-font graphics for credits scenes
C3E633:  LDY #$568F      ; Source LBs
         LDA #$D9        ; Source HB
         JMP C3ECB1      ; Unpack data

; Upload non-font sprite graphics for credits scenes
C3E63B:  LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$17BA      ; Bytes: 6074
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$6000      ; VRAM pointer
         JMP C3ED09      ; Upload data

; Relocate decompressed data, adjust attributes if tilemap
C3E653:  STZ $F1         ; ...
         STZ $F2         ; ...
         REP #$20        ; 16-bit A
         LDY $00         ; Index: 0
C3E65B:  LDA [$E7],Y     ; Unpacked data
         CLC             ; ...
         ADC $F1         ; ...
         STA [$EB],Y     ; Put in buffer
         INY             ; Index +1
         INY             ; Index +1
         CPY $EF         ; Past range?
         BNE C3E65B      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Add a 128x64 tilemap to Mode 7 map
C3E66B:  TDC             ; Clear A
         TAY             ; Index: 0
C3E66D:  REP #$20        ; 16-bit A
         LDA [$F7],Y     ; Src index
         TAX             ; Save in X
         INY             ; Index +1
         INY             ; Index +1
         LDA [$F7],Y     ; Dst index
         STA $E7         ; Memorize it
         INY             ; Index +1
         INY             ; Index +1
         SEP #$20        ; 8-bit A
         PHY             ; Save index
         TXY             ; Src index
         JSR C3E688      ; Copy 32x32 map
         PLY             ; Restore index
         CPY #$0020      ; Done 8 maps?
         BNE C3E66D      ; Loop if not
         RTS

; Add a 32x32 tilemap to Mode 7 map
C3E688:  PHB             ; Save DB
         LDA #$7F        ; Bank: 7F
         PHA             ; Put on stack
         PLB             ; Set DB to 7F
         LDA #$20        ; Rows: 32
         STA $E0         ; Set counter
C3E691:  LDA #$20        ; Columns: 32
         STA $E1         ; Set counter
         LDX $E7         ; Dst index
C3E697:  LDA [$F1],Y     ; Tile number
         STA $B800,X     ; Add to M7 map
         INY             ; Src index +1
         INX             ; Dst index +1
         INX             ; Dst index +1
         DEC $E1         ; One less column
         BNE C3E697      ; Loop till last
         REP #$21        ; 16-bit A; C-
         LDA $E7         ; Dst index
         ADC #$0100      ; +128 tiles
         STA $E7         ; Save changes
         SEP #$20        ; 8-bit A
         DEC $E0         ; One less row
         BNE C3E691      ; Loop till last
         PLB             ; Restore DB
         RTS

; Add 4bpp tile graphics to Mode 7 map
C3E6B4:  STA $E9         ; Set src HB
         STX $E7         ; Set src LBs
         PHB             ; Save DB
         LDA #$7F        ; Bank: 7F
         PHA             ; Put on stack
         PLB             ; Set DB to 7F
         TDC             ; Clear A
         TAX             ; Dst index: 0
C3E6BF:  LDA #$08        ; Rows left: 8
         STA $E6         ; Set counter

; Fork: Load 8-pixel row
C3E6C3:  REP #$20        ; 16-bit A
         LDY #$0010      ; Src index: 16
         LDA [$E7]       ; Planes A & B
         STA $F1         ; Memorize them
         LDA [$E7],Y     ; Planes C & D
         STA $EF         ; Memorize them
         TDC             ; ...
         SEP #$20        ; 8-bit A

; Fork: Convert each pixel in row
C3E6D3:  LDY #$0008      ; Pixels: 8
C3E6D6:  TDC             ; Clear A
         ASL $F0         ; Get plane D
         ROL A           ; Roll into A
         ASL $EF         ; Get plane C
         ROL A           ; Roll into A
         ASL $F2         ; Get plane B
         ROL A           ; Roll into A
         ASL $F1         ; Get plane A
         ROL A           ; Roll into A
         AND #$0F        ; Blank pixel?
         BEQ C3E6F7      ; Branch if so
         STA $E0         ; Save 0-15 color
         PHY             ; Save pixels left
         LDY $E4         ; Palette index
         LDA [$91],Y     ; Palette number
         PLY             ; Pixels left
         ASL A           ; Palette x2
         ASL A           ; Palette x4
         ASL A           ; Palette x8
         ASL A           ; Palette x16
         AND #$F0        ; ...
         ORA $E0         ; Add 0-15 color
C3E6F7:  STA $B801,X     ; Set map pixel
         INX             ; Dst index +1
         INX             ; Dst index +1
         DEY             ; One less pixel
         BNE C3E6D6      ; Loop till last

; Fork: Do tile's next row
C3E6FF:  LDY $E7         ; Source
         INY             ; Source +1
         INY             ; Source +1
         STY $E7         ; Save changes
         DEC $E6         ; One less row
         BNE C3E6C3      ; Loop till last

; Fork: Do next tile
C3E709:  REP #$20        ; 16-bit A
         INC $E4         ; Pal index +1
         LDA $E7         ; Source
         CLC             ; Prepare ADC
         ADC #$0010      ; Skip done data
         STA $E7         ; Save changes
         TDC             ; Clear A
         SEP #$20        ; 8-bit A
         DEC $ED         ; One less tile
         BNE C3E6BF      ; Loop till last
         PLB             ; Restore DB
         RTS

; Handle credits timing for sideview airship scene
C3E71E:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$003C      ; 60?
         BNE C3E72D      ; Exit if not
         JSR C3E95E      ; Init producer
C3E72D:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Handle credits timing for aerial-view airship scene
C3E730:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$000A      ; 10?
         BNE C3E741      ; Branch if not
         JSR C3E969      ; Init director
         BRA C3E77B      ; Exit

; Fork: Main programmer
C3E741:  CPY #$01AE      ; 430?
         BNE C3E74B      ; Branch if not
         JSR C3E974      ; Init sprites
         BRA C3E77B      ; Exit

; Fork: Graphic director (page 1)
C3E74B:  CPY #$0352      ; 850?
         BNE C3E755      ; Branch if not
         JSR C3E97F      ; Init sprites
         BRA C3E77B      ; Exit

; Fork: Graphic director (page 2)
C3E755:  CPY #$04F6      ; 1270?
         BNE C3E75F      ; Branch if not
         JSR C3E98A      ; Init sprites
         BRA C3E77B      ; Exit

; Fork: Music
C3E75F:  CPY #$069A      ; 1690?
         BNE C3E769      ; Branch if not
         JSR C3E995      ; Init sprites
         BRA C3E77B      ; Exit

; Fork: Image design
C3E769:  CPY #$083E      ; 2110?
         BNE C3E773      ; Branch if not
         JSR C3E9A0      ; Init sprites
         BRA C3E77B      ; Exit

; Fork: Battle planner
C3E773:  CPY #$09E2      ; 2530?
         BNE C3E77B      ; Exit if not
         JSR C3E9AB      ; Init sprites
C3E77B:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Handle credits timing for boat scene
C3E77E:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$000A      ; 10?
         BNE C3E78F      ; Branch if not
         JSR C3E9B6      ; Init field pln
         BRA C3E7AB      ; Exit

; Fork: Event planner
C3E78F:  CPY #$01AE      ; 430?
         BNE C3E799      ; Branch if not
         JSR C3E9C1      ; Init sprites
         BRA C3E7AB      ; Exit

; Fork: Effect programmer
C3E799:  CPY #$0352      ; 850?
         BNE C3E7A3      ; Branch if not
         JSR C3E9CC      ; Init sprites
         BRA C3E7AB      ; Exit

; Fork: Battle programmer
C3E7A3:  CPY #$04F6      ; 1270?
         BNE C3E7AB      ; Exit if not
         JSR C3E9D7      ; Init sprites
C3E7AB:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Handle credits timing for skimming airship scene
C3E7AE:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$000A      ; 10?
         BNE C3E7BF      ; Branch if not
         JSR C3E9E2      ; Init sound prg
         BRA C3E7F9      ; Exit

; Fork: Effect graphic designer
C3E7BF:  CPY #$01AE      ; 430?
         BNE C3E7C9      ; Branch if not
         JSR C3E9ED      ; Init sprites
         BRA C3E7F9      ; Exit

; Fork: Field graphic designer (page 1)
C3E7C9:  CPY #$0352      ; 850?
         BNE C3E7D3      ; Branch if not
         JSR C3E9F8      ; Init sprites
         BRA C3E7F9      ; Exit

; Fork: Field graphic designer (page 2)
C3E7D3:  CPY #$04F6      ; 1270?
         BNE C3E7DD      ; Branch if not
         JSR C3EA03      ; Init sprites
         BRA C3E7F9      ; Exit

; Fork: Field graphic designer (page 3)
C3E7DD:  CPY #$069A      ; 1690?
         BNE C3E7E7      ; Branch if not
         JSR C3EA0E      ; Init sprites
         BRA C3E7F9      ; Exit

; Fork: Monster graphic designer
C3E7E7:  CPY #$083E      ; 2110?
         BNE C3E7F1      ; Branch if not
         JSR C3EA19      ; Init sprites
         BRA C3E7F9      ; Exit

; Fork: Object graphic designer
C3E7F1:  CPY #$09E2      ; 2530?
         BNE C3E7F9      ; Exit if not
         JSR C3EA24      ; Init sprites
C3E7F9:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Handle credits timing for frontview airship scene
C3E7FC:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$000A      ; 10?
         BNE C3E80D      ; Branch if not
         JSR C3EA2F      ; Init sound eng
         BRA C3E847      ; Exit

; Fork: Sound effect (page 1)
C3E80D:  CPY #$01AE      ; 430?
         BNE C3E817      ; Branch if not
         JSR C3EA3A      ; Init sprites
         BRA C3E847      ; Exit

; Fork: Sound effect (page 2)
C3E817:  CPY #$0352      ; 850?
         BNE C3E821      ; Branch if not
         JSR C3EA45      ; Init sprites
         BRA C3E847      ; Exit

; Fork: Remake planner					=== SNES: Adds translator
C3E821:  CPY #$04F6      ; 1270?
         BNE C3E82B      ; Branch if not
         JSR C3EA50      ; Init sprites
         BRA C3E847      ; Exit

; Fork: System engineer (page 1)
C3E82B:  CPY #$069A      ; 1690?
         BNE C3E835      ; Branch if not
         JSR C3EA5B      ; Init sprites
         BRA C3E847      ; Exit

; Fork: System engineer (page 2)
C3E835:  CPY #$083E      ; 2110?
         BNE C3E83F      ; Branch if not
         JSR C3EA66      ; Init sprites
         BRA C3E847      ; Exit

; Fork: Executive producer
C3E83F:  CPY #$09E2      ; 2530?
         BNE C3E847      ; Exit if not
         JSR C3EA71      ; Init sprites
C3E847:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Handle credits timing for aerial-view plains scene
C3E84A:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$00F0      ; 240?
         BNE C3E85B      ; Branch if not
         JSR C3EA7C      ; Init test coord
         BRA C3E895      ; Exit

; Fork: Special thanks (page 1)
C3E85B:  CPY #$02D0      ; 720?
         BNE C3E865      ; Branch if not
         JSR C3EA87      ; Init sprites
         BRA C3E895      ; Exit

; Fork: Special thanks (page 2)
C3E865:  CPY #$04B0      ; 1200?
         BNE C3E86F      ; Branch if not
         JSR C3EA92      ; Init sprites
         BRA C3E895      ; Exit

; Fork: Special thanks (page 3)
C3E86F:  CPY #$0690      ; 1680?
         BNE C3E879      ; Branch if not
         JSR C3EA9D      ; Init sprites
         BRA C3E895      ; Exit

; Fork: Special thanks (page 4)
C3E879:  CPY #$0870      ; 2160?
         BNE C3E883      ; Branch if not
         JSR C3EAA8      ; Init sprites
         BRA C3E895      ; Exit

; Fork: Special thanks (page 5)
C3E883:  CPY #$0A50      ; 2640?
         BNE C3E88D      ; Branch if not
         JSR C3EAB3      ; Init sprites
         BRA C3E895      ; Exit

; Fork: Special thanks (page 6)
C3E88D:  CPY #$0C30      ; 3120?
         BNE C3E895      ; Exit if not
         JSR C3EABE      ; Init sprites
C3E895:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Handle credits timing for rearview airship scene
C3E898:  PHB             ; Save DB
         LDA #$C3        ; ...
         PHA             ; ...
         PLB             ; ...
         LDY $CF         ; Scene timer
         CPY #$00F0      ; 240?				=== SNES timing differs
         BNE C3E8A9      ; Branch if not
         JSR C3EAC9      ; Init thanks_p7
         BRA C3E8C5      ; Exit

; Fork: Special thanks (page 8)
C3E8A9:  CPY #$02D0      ; 720?				=== SNES timing differs
         BNE C3E8B3      ; Branch if not
         JSR C3EAD4      ; Init sprites
         BRA C3E8C5      ; Exit

; Fork: Special thanks (page 9)
C3E8B3:  CPY #$04B0      ; 1200?			=== SNES timing differs
         BNE C3E8BD      ; Branch if not
         JSR C3EADF      ; Init sprites
         BRA C3E8C5      ; Exit

; Fork: Special thanks (page 10)
C3E8BD:  CPY #$0690      ; 1680?			=== SNES timing differs
         BNE C3E8C5      ; Exit if not
         JSR C3EAEA      ; Init sprites






C3E8C5:  PLB             ; Restore DB
         SEC             ; Set to requeue
         RTS

; Build credits' OAM table for sideview airship scene
C3E8C8:  LDX #$9DA4      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0004      ; Sprites: 1
         JSR C3E94C      ; Do position
         LDX #$9C30      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0008      ; Sprites: 2
         JMP C3E955      ; Do staff

; Build credits' OAM table for aerial-view airship scene
C3E8DE:  LDX #$9DA8      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0028      ; Sprites: 10
         JSR C3E94C      ; Do positions
         LDX #$9C38      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0060      ; Sprites: 24
         JMP C3E955      ; Do staff

; Build credits' OAM table for boat scene
C3E8F4:  LDX #$9DD0      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0018      ; Sprites: 6
         JSR C3E94C      ; Do positions
         LDX #$9C98      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0040      ; Sprites: 16
         JMP C3E955      ; Do staff

; Build credits' OAM table for skimming airship scene
C3E90A:  LDX #$9DE8      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0020      ; Sprites: 8
         JSR C3E94C      ; Do positions
         LDX #$9CD8      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0064      ; Sprites: 25
         JMP C3E955      ; Do staff

; Build credits' OAM table for frontview airship scene
C3E920:  LDX #$9E08      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0020      ; Sprites: 8			=== SNES: 9
         JSR C3E94C      ; Do positions
         LDX #$9D3C      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0068      ; Sprites: 26			=== SNES: 28
         JMP C3E955      ; Do staff

; Build credits' OAM table for aerial-view plains scene
C3E936:  LDX #$9E28      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$00E8      ; Sprites: 58			=== SNES: 57
         JMP C3E94C      ; Build OAM

; Build credits' OAM table for rearview airship scene
C3E941:  LDX #$9F10      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         LDY #$0068      ; Sprites: 26			=== SNES: 27
         JMP C3E94C      ; ...

; Build OAM table for scene's small credits strings; set source
C3E94C:  STX $4A         ; Set src LBs
         STA $4C         ; Set src HB
         STY $4D         ; Set range end
         JMP C3EB18      ; Build tables

; Build OAM table for scene's large credits strings; set source
C3E955:  STX $4A         ; Set src LBs
         STA $4C         ; Set src HB
         STY $4D         ; Set range end
         JMP C3EB38      ; Build tables

; Initialize credits for producer
C3E95E:  LDY #$000C      ; Sprites: 3
         LDX #$988C      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for director
C3E969:  LDY #$0014      ; Sprites: 5
         LDX #$9898      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for main programmer
C3E974:  LDY #$0018      ; Sprites: 6
         LDX #$98AC      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for graphic director, page 1
C3E97F:  LDY #$0018      ; Sprites: 6
         LDX #$98C4      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for graphic director, page 2
C3E98A:  LDY #$0018      ; Sprites: 6
         LDX #$98DC      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for music
C3E995:  LDY #$000C      ; Sprites: 3
         LDX #$98F4      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for image design
C3E9A0:  LDY #$0010      ; Sprites: 4
         LDX #$9900      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for battle planner
C3E9AB:  LDY #$0018      ; Sprites: 6
         LDX #$9910      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for field planner
C3E9B6:  LDY #$0020      ; Sprites: 8
         LDX #$9928      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for event planner
C3E9C1:  LDY #$0018      ; Sprites: 6
         LDX #$9948      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for effect programmer
C3E9CC:  LDY #$0018      ; Sprites: 6
         LDX #$9960      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for battle programmer
C3E9D7:  LDY #$0010      ; Sprites: 4
         LDX #$9978      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for sound programmer
C3E9E2:  LDY #$0010      ; Sprites: 4
         LDX #$9988      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for effect graphic designer
C3E9ED:  LDY #$0014      ; Sprites: 5
         LDX #$9998      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for field graphic designer, page 1
C3E9F8:  LDY #$0024      ; Sprites: 9
         LDX #$99AC      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for field graphic designer, page 2
C3EA03:  LDY #$0024      ; Sprites: 9
         LDX #$99D0      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for field graphic designer, page 3
C3EA0E:  LDY #$0024      ; Sprites: 9
         LDX #$99F4      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for monster graphic designer
C3EA19:  LDY #$0014      ; Sprites: 5
         LDX #$9A18      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for object graphic designer
C3EA24:  LDY #$0014      ; Sprites: 5
         LDX #$9A2C      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for sound engineer
C3EA2F:  LDY #$0010      ; Sprites: 4
         LDX #$9A40      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for sound effect, page 1
C3EA3A:  LDY #$0018      ; Sprites: 6
         LDX #$9A50      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for sound effect, page 2
C3EA45:  LDY #$0018      ; Sprites: 6
         LDX #$9A68      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for remake planner			=== SNES: Adds translator
C3EA50:  LDY #$0018      ; Sprites: 6			=== SNES: 9
         LDX #$9A80      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for system engineer, page 1
C3EA5B:  LDY #$0018      ; Sprites: 6
         LDX #$9A98      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for system engineer, page 2
C3EA66:  LDY #$0018      ; Sprites: 6
         LDX #$9AB0      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for executive producer
C3EA71:  LDY #$0018      ; Sprites: 6
         LDX #$9AC8      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for test coordinator
C3EA7C:  LDY #$0028      ; Sprites: 10
         LDX #$9AE0      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 1
C3EA87:  LDY #$0028      ; Sprites: 10
         LDX #$9B08      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 2
C3EA92:  LDY #$0024      ; Sprites: 9
         LDX #$9B30      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 3
C3EA9D:  LDY #$0020      ; Sprites: 8
         LDX #$9B54      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 4
C3EAA8:  LDY #$0018      ; Sprites: 6
         LDX #$9B74      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 5
C3EAB3:  LDY #$0014      ; Sprites: 5
         LDX #$9B8C      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 6
C3EABE:  LDY #$0028      ; Sprites: 10			=== SNES: 9
         LDX #$9BA0      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 7
C3EAC9:  LDY #$0018      ; Sprites: 6
         LDX #$9BC8      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 8
C3EAD4:  LDY #$0018      ; Sprites: 6
         LDX #$9BE0      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 9
C3EADF:  LDY #$001C      ; Sprites: 7			=== SNES: 5
         LDX #$9BF8      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; Init sprites

; Initialize credits for special thanks, page 10
C3EAEA:  LDY #$001C      ; Sprites: 7			=== SNES: 5
         LDX #$9C14      ; Source LBs			=== SNES address differs
         LDA #$C2        ; Source HB
         JMP C3EAF5      ; ...







; Initialize sprites for current credits strings
C3EAF5:  STY $FA         ; Set src range
         STX $F7         ; Set src LBs
         STA $F9         ; Set src HB
         LDY $00         ; Index: 0
C3EAFD:  REP #$20        ; 16-bit A
         LDA [$F7],Y     ; Anim table ptr
         TAX             ; Save in X
         INY             ; Index +1
         INY             ; Index +1
         LDA [$F7],Y     ; Position
         STA $60         ; Memorize it
         SEP #$20        ; 8-bit A
         PHY             ; Save index
         TXY             ; Anim table ptr
         JSR C3EB64      ; Init sprite
         PLY             ; Table index
         INY             ; Index +1
         INY             ; Index +1
         CPY $FA         ; Past range?
         BNE C3EAFD      ; Loop if not
         SEC             ; ...
         RTS

; Build OAM table for scene's small credits strings
C3EB18:  LDY $00         ; Index: 0
C3EB1A:  JSR C3EB58      ; Get attribs
         REP #$20        ; 16-bit A
         LDA [$4A],Y     ; Text ptr
         TAX             ; Put in X
         INY             ; Index +1
         INY             ; Index +1
         LDA [$4A],Y     ; Dest LBs
         STA $E7         ; Memorize it
         INY             ; Index +1
         INY             ; Index +1
         PHY             ; Save index
         LDY $E7         ; Dest LBs
         SEP #$20        ; 8-bit A
         JSR C3EC0C      ; Build table
         PLY             ; Pointer index
         CPY $4D         ; Past range?
         BNE C3EB1A      ; Loop if not
         RTS

; Build OAM table for scene's large credits strings
C3EB38:  LDY $00         ; Index: 0
C3EB3A:  JSR C3EB5E      ; Get attribs
         REP #$20        ; 16-bit A
         LDA [$4A],Y     ; Source LBs
         TAX             ; Save in X
         INY             ; Index +1
         INY             ; Index +1
         LDA [$4A],Y     ; Dest LBs
         STA $E7         ; Save them
         INY             ; Index +1
         INY             ; Index +1
         PHY             ; Save index
         LDY $E7         ; Dest LBs
         SEP #$20        ; 8-bit A
         JSR C3EC21      ; Build table
         PLY             ; Pointer index
         CPY $4D         ; Past range?
         BNE C3EB3A      ; Loop if not
         RTS

; Set attribute complements for small credits
C3EB58:  LDX #$0B00      ; ADR+, pal 5
         STX $F1         ; Save attribs
         RTS

; Set attribute complements for large credits
C3EB5E:  LDX #$0900      ; ADR+, pal 4
         STX $F1         ; Set attribs
         RTS

; Initialize sprite for current credit string
C3EB64:  STY $F1         ; Save anim ptr
         STZ $AF         ; Request fade-in
         LDA #$00        ; Min slot: 0
         LDY #C3EB94     ; C3/EB94
         JSR C311DE      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA $F1         ; Anim table ptr
         STA $7E32C9,X   ; Set sprite's
         LDA #$01A4      ; Frames: 420
         STA $7E3349,X   ; Set hide delay
         SEP #$20        ; 8-bit A
         LDA #$7E        ; Bank: 7E
         STA $7E35CA,X   ; Set ptr HB
         LDA $60         ; X position
         STA $7E33CA,X   ; Set sprite's
         LDA $61         ; Y position
         STA $7E344A,X   ; Set sprite's
         RTS

; Animate credit string
C3EB94:  TAX             ; Index mode
         JMP (C3EB98,X)  ; Handle mode

; Jump table for the above
C3EB98:  dw C3EB9C       ; Initialize sprite
         dw C3EBD4       ; Sustain sprite

; Mode 0: Initialize sprite
C3EB9C:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA $344A,X     ; Sprite's Y
         CLC             ; Prepare ADC
         ADC #$20        ; Go 32 px down
         STA $344A,X     ; Save changes
         REP #$20        ; 16-bit A
         LDA #$FF80      ; V-Spd: -0.5 px
         STA $3549,X     ; Set sprite's
         STZ $34C9,X     ; H-Speed: 0
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer
         LDA $AF         ; Handled fade-in?
         BNE C3EBD4      ; Skip it if so
         PHB             ; Save DB
         LDA #$00        ; Bank: 00
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         LDA $B4         ; Text on clouds?
         BNE C3EBCC      ; Use blue if so
         JSR C3D675      ; Fade-in: White
         BRA C3EBCF      ; Skip a line
C3EBCC:  JSR C3D69C      ; Fade-in: Blue
C3EBCF:  LDA #$01        ; Mark as handled
         STA $AF         ; Allow fade-out
         PLB             ; Restore DB

; Mode 1: Sustain sprite
C3EBD4:  LDX $2D         ; Queue index
         LDY $3349,X     ; Mode expired?
         BEQ C3EBF9      ; Delete if so
         CPY #$0164      ; 356?
         BNE C3EBE6      ; Scroll if not
         STZ $3549,X     ; V-Speed LB: 0
         STZ $354A,X     ; V-Speed HB: 0
C3EBE6:  CPY #$0080      ; 128?
         BEQ C3EBFB      ; Fade if so
C3EBEB:  JSR C3EE10      ; Scroll & OAM
         LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         DEC $3349,X     ; Timer -1
         SEP #$20        ; 8-bit A
         SEC             ; Set to requeue
         RTS             ; Exit
C3EBF9:  CLC             ; Set to dequeue
         RTS

; Fork: Set to fade all text
C3EBFB:  LDA $AF         ; Already set?
         BEQ C3EBEB      ; Skip if so
         STZ $AF         ; Mark as handled
         PHB             ; Save DB
         LDA #$00        ; Bank: 00
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         JSR C3D64E      ; Trigger fade
         PLB             ; Restore DB
         BRA C3EBEB      ; Scroll & OAM

; Build OAM table for small credit string
C3EC0C:  JSR C3EC81      ; Set OAM tbl ptr
         JSR C3EC75      ; Set size, rel X
C3EC12:  JSR C3EC52      ; Set a char's OAM
         BCC C3EC20      ; Exit if no more
         LDA $E0         ; Relative X
         CLC             ; Prepare ADC
         ADC #$08        ; Go 8 px right
         STA $E0         ; Save changes
         BRA C3EC12      ; Do next letter
C3EC20:  RTS

; Build OAM table for large credit string
C3EC21:  JSR C3EC81      ; Set OAM tbl ptr
         JSR C3EC75      ; Set size, rel X
C3EC27:  TDC             ; ...
         LDA [$E7]       ; At terminator?
         BEQ C3EC51      ; Exit if so
         STA $E3         ; Save letter
         LDA $E0         ; Relative X
         ORA #$80        ; Add 16x16 flag
         STA [$EB],Y     ; Set for letter
         INY             ; Index +1
         TDC             ; Relative Y: 0
         STA [$EB],Y     ; Set letter's
         INY             ; Index +1
         TDC             ; ...
         LDA $E3         ; Letter
         REP #$21        ; 16-bit A; C-
         ADC $F1         ; Add attribs
         STA [$EB],Y     ; Set attribs
         INC $E7         ; Letter +1
         INY             ; Index +1
         INY             ; Index +1
         SEP #$20        ; 8-bit A
         LDA $E0         ; Relative X
         CLC             ; Prepare ADC
         ADC #$08        ; Go 8 px right
         STA $E0         ; Save changes
         BRA C3EC27      ; Do next letter
C3EC51:  RTS

; Build OAM for small credit letter, clear Carry if terminator
C3EC52:  TDC             ; ...
         LDA [$E7]       ; At terminator?
         BEQ C3EC73      ; Exit if so
         STA $E3         ; Save letter
         LDA $E0         ; Relative X
         STA [$EB],Y     ; Set letter's
         INY             ; Index +1
         TDC             ; Relative Y: 0
         STA [$EB],Y     ; Set letter's
         INY             ; Index +1
         TDC             ; ...
         LDA $E3         ; Letter
         REP #$21        ; 16-bit A; C-
         ADC $F1         ; Add attribs
         STA [$EB],Y     ; Set attribs
         INC $E7         ; Letter +1
         INY             ; Index +1
         INY             ; Index +1
         SEP #$20        ; 8-bit A
         SEC             ; End: No
         RTS             ; Exit
C3EC73:  CLC             ; End: Yes
         RTS

; Set credit string's size and reset relative X position
C3EC75:  LDY $00         ; Index: 0
         STA [$EB],Y     ; Set size
         INY             ; Index +1
         STZ $E0         ; Rel X: 0
         STZ $EF         ; No use...
         STZ $F0         ; No use...
         RTS

; Set OAM table pointer for credit string, compute string size
C3EC81:  STX $E7         ; Set src LBs
         LDA #$C2        ; Bank: C2
         STA $E9         ; Set src HB
         STY $EB         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
         REP #$21        ; 16-bit A; C-
         LDA $EB         ; Dest LBs
         ADC #$0003      ; +3 bytes
         STA [$EB]       ; Set OAM ptr
         INC $EB         ; Dst LBs +1
         INC $EB         ; Dst LBs +1
         SEP #$20        ; 8-bit A
         LDA #$FE        ; Time: Infinite
         STA [$EB]       ; Set pose timer
         INC $EB         ; Dst LBs +1
         LDY $00         ; Letter: 1st
         TYX             ; Tile count: 0
C3ECA5:  LDA [$E7],Y     ; Letter
         INY             ; Point to next
         CMP #$00        ; Terminator?
         BEQ C3ECAF      ; Exit if so
         INX             ; Tile count +1
         BRA C3ECA5      ; Do next letter
C3ECAF:  TXA             ; String size
         RTS

; Decompress data
C3ECB1:  STY $F3         ; Set src LBs
         STA $F5         ; Set src HB
         LDY #$C000      ; 7E/C000
         STY $F6         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $F8         ; Set dst HB
         JSL $C2FF6D     ; Unpack data
         RTS

; Clear VRAM
C3ECC3:  REP #$20        ; 16-bit A
         TDC             ; $0000
         STA $2116       ; Set VRAM ptr
         TAY             ; Counter: 0
C3ECCA:  STA $2118       ; Zero VRAM word
         INY             ; Counter +1
         CPY #$8000      ; Done all VRAM?
         BNE C3ECCA      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Convert and upload graphics for range of font characters
C3ECD6:  STY $2116       ; Set VRAM ptr
         TDC             ; Clear A
         TAY             ; Index: 0
         REP #$20        ; 16-bit A
C3ECDD:  LDX #$0008      ; 8-px rows: 8
C3ECE0:  LDA [$E7],Y     ; 8 px, 2 planes
         STA $2118       ; Save in VRAM
         INY             ; Index +1
         INY             ; Index +1
         DEX             ; One less row
         BNE C3ECE0      ; Loop till last
         STZ $2118       ; Planes 1C, 1D
         STZ $2118       ; Planes 2C, 2D
         STZ $2118       ; Planes 3C, 3D
         STZ $2118       ; Planes 4C, 4D
         STZ $2118       ; Planes 5C, 5D
         STZ $2118       ; Planes 6C, 6D
         STZ $2118       ; Planes 7C, 7D
         STZ $2118       ; Planes 8C, 8D
         CPY $EB         ; More tiles?
         BNE C3ECDD      ; Loop if so
         SEP #$20        ; 8-bit A
         RTS

; Upload data manually, adjust attributes if tilemap
C3ED09:  REP #$20        ; 16-bit A
         TYA             ; VRAM pointer
         STA $2116       ; To register
         TDC             ; Clear A
         TAY             ; Index: 0
C3ED11:  LDA [$E7],Y     ; Source data
         CLC             ; Prepare ADC
         ADC $ED         ; Add attribs
         STA $2118       ; Save in VRAM
         INY             ; Index +1
         INY             ; Index +1
         CPY $EB         ; Past range?
         BNE C3ED11      ; Loop if not
         SEP #$20        ; 8-bit A
         RTS

; Build Mode 7 matrix tables for HDMA
C3ED22:  PHB             ; Save DB
         LDA #$00        ; Bank: 00
         PHA             ; Put on stack
         PLB             ; Set DB to 0
         REP #$20        ; 16-bit A

; Fork: Define scale dividend
C3ED29:  LDA $C3         ; Dividend index
         JSR C3EDC6      ; Signed dividend
         STA $E0         ; ...
         STA $EB         ; Memorize it
         LDA $E0         ; Positive?
         BPL C3ED3A      ; Branch if so
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
C3ED3A:  STA $E0         ; ...
         LSR A           ; Halve it
         STA $CB         ; Save dividend

; Fork: Define shear dividend
C3ED3F:  LDA $C3         ; Dividend index
         JSR C3EDCA      ; Signed dividend
         STA $E0         ; ...
         STA $ED         ; Memorize it
         LDA $E0         ; Positive?
         BPL C3ED50      ; Branch if so
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
C3ED50:  STA $E0         ; ...
         LSR A           ; Halve it
         STA $C9         ; Save dividend

; Fork: Define matrices A and D for two scanlines
C3ED55:  LDY #$01C0      ; Scanline: Last		=== SNES: #$01BE (makes no difference)
         LDA $C5         ; Base divisor
         STA $E7         ; Memorize it
C3ED5C:  LDA $CB         ; Scale dividend
         STA $4204       ; To register
         SEP #$20        ; 8-bit A
         LDA $E8         ; Map factor HB
         STA $4206       ; Set divisor
         NOP
         NOP
         NOP
         NOP
         NOP
         REP #$20        ; 16-bit A
         LDA $EB         ; Positive mod?
         BPL C3ED7C      ; Branch if so
         LDA $4214       ; Quotient
         EOR #$FFFF      ; Invert value
         INC A           ; Add 1
         BRA C3ED7F      ; Skip a line
C3ED7C:  LDA $4214       ; Quotient
C3ED7F:  STA $0602,Y     ; Set line 1
         STA $0604,Y     ; Set line 2

; Fork: Define matrices B and C for two scanlines
C3ED85:  LDA $C9         ; Shear dividend
         STA $4204       ; To register
         SEP #$20        ; 8-bit A
         LDA $E8         ; Map factor HB
         STA $4206       ; Set divisor
         NOP
         NOP
         REP #$20        ; 16-bit A
         LDA $E7         ; Matrix divisor
         SEC             ; Prepare SBC
         SBC $C7         ; Deduct "angle"
         STA $E7         ; Save changes
         LDA $ED         ; Positive mod?
         BPL C3EDA9      ; Branch if so
         LDA $4214       ; Quotient
         EOR #$FFFF      ; Invert it
         INC A           ; Add 1
         BRA C3EDAC      ; Skip a line
C3EDA9:  LDA $4214       ; Quotient
C3EDAC:  STA $07C4,Y     ; Set line B1
         STA $07C6,Y     ; Set line B2
         EOR #$FFFF      ; Invert it
         INC A           ; Add 1
         STA $0986,Y     ; Set line C1
         STA $0988,Y     ; Set line C2
         DEY             ; Index -1
         DEY             ; Index -1
         DEY             ; Index -1
         DEY             ; Index -1
         BPL C3ED5C      ; Loop if > 0
         SEP #$20        ; 8-bit A
         PLB             ; Restore DB
         RTS

; Load animation modifier
C3EDC6:  CLC             ; Prepare ADC
         ADC #$0040      ; Index +64
C3EDCA:  AND #$00FF      ; Clear HB
         ASL A           ; Double it
         TAX             ; Index it
         LDA $C2FC6D,X   ; Modifier
         RTS

; Animate linearly moving temporary sprite
C3EDD4:  TAX             ; Index mode
         JMP (C3EDD8,X)  ; Handle mode

; Jump table for the above
C3EDD8:  dw C3EDDC       ; Initialize timer
         dw C3EDE4       ; Sustain sprite

; Mode 0: Initialize timer
C3EDDC:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3EDE4:  LDX $2D         ; Queue index
         LDY $3349,X     ; Timer expired?
         BEQ C3EDF9      ; Delete if so
         JSR C3EE10      ; Scroll & OAM
         LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         DEC $3349,X     ; Timer -1
         SEP #$20        ; 8-bit A
         SEC             ; Set to requeue
         RTS             ; Exit
C3EDF9:  CLC             ; Set to dequeue
         RTS

; Animate regular permanent sprite
C3EDFB:  TAX             ; Index mode
         JMP (C3EDFF,X)  ; Handle mode

; Jump table for the above
C3EDFF:  dw C3EE03       ; Initialize timer
         dw C3EE0B       ; Sustain sprite

; Mode 0: Initialize timer
C3EE03:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3EE0B:  JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Scroll sprite and define OAM
C3EE10:  LDX $2D         ; Queue index
         REP #$21        ; 16-bit A; C-
         LDA $33C9,X     ; Fractional X
         ADC $34C9,X     ; Add H-Speed
         STA $33C9,X     ; Save changes
         LDA $3449,X     ; Fractional Y
         CLC             ; Prepare ADC
         ADC $3549,X     ; Add V-Speed
         STA $3449,X     ; Save changes
         SEP #$20        ; ...
         JSR C3128C      ; Define OAM
         RTS

; Animate true actor name or "And you"
C3EE2D:  STA $E0         ; Save mode
         LDA $47         ; At 2nd actor?
         BNE C3EE39      ; Delete if so
         LDA $E0         ; Anim mode
         TAX             ; Index it
         JMP (C3EE3B,X)  ; Handle mode
C3EE39:  CLC             ; Set to dequeue
         RTS

; Jump table for the above
C3EE3B:  dw C3EE4F       ; Initialize sprite
         dw C3EE63       ; Refresh sprite
         dw C3EE6B       ; Set to scroll up
         dw C3EE63       ; Refresh sprite
         dw C3EE73       ; Stop scrolling
         dw C3EE63       ; Refresh sprite
         dw C3EE7A       ; Set to scroll up
         dw C3EE63       ; Refresh sprite
         dw C3EE4D       ; Delete sprite

; Mode 8: Delete sprite
C3EE4D:  CLC             ; Set to dequeue
         RTS

; Mode 0: Initialize sprite
C3EE4F:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         STZ $3549,X     ; V-Speed: 0
         LDA $85         ; Scroll delay
         STA $3349,X     ; Set mode timer
         SEP #$20        ; 8-bit A
         JSR C31271      ; Set pose timer

; Modes 1, 3, 5: Refresh sprite
C3EE63:  JSR C3EE9B      ; Mode timer -1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Mode 2: Set to scroll upward 2.5s
C3EE6B:  LDY #$FFC0      ; V-Spd: -0.25 px
         LDX #$0096      ; Frames: 150
         BRA C3EE82      ; Set spd, timer

; Mode 4: Stop scrolling
C3EE73:  LDY $00         ; V-Speed: 0
         LDX #$00F0      ; Frames: 240
         BRA C3EE82      ; Set spd, timer

; Mode 6: Set to scroll upward 5s
C3EE7A:  LDY #$FFC0      ; V-Spd: -0.25 px
         LDX #$012C      ; Frames: 300
         BRA C3EE82      ; ...

; Fork: Change V-Speed and mode timer
C3EE82:  STY $E7         ; Save V-Speed
         STX $E9         ; Save timer
         LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $E7         ; V-Speed
         STA $3549,X     ; Set sprite's
         LDA $E9         ; Mode timer
         STA $3349,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         INC $3649,X     ; Mode +1
         BRA C3EE63      ; Scroll & OAM

; Decrease animation timer, advance mode if expired
C3EE9B:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $3349,X     ; Timer expired?
         BNE C3EEA9      ; Branch if not
         INC $3649,X     ; Mode +1
         BRA C3EEAC      ; Skip a line
C3EEA9:  DEC $3349,X     ; Timer -1
C3EEAC:  SEP #$20        ; 8-bit A
         RTS

; Draw, center, and set to upload actor's pseudonym
C3EEAF:  LDY $00         ; 1st: Terra
C3EEB1:  STY $EB         ; Save slot
         REP #$20        ; 16-bit A
         TYA             ; Actor slot
         ASL A           ; Double it
         TAX             ; Index it
         LDA.L C370DB,X  ; Actor's address
         TAY             ; Index it
         SEP #$20        ; 8-bit A
         LDA $0000,Y     ; Actor in slot
         CMP $28         ; Matches ours?
         BEQ C3EEE9      ; Proceed if so
         REP #$21        ; ...
         LDA #$0025      ; ...
         ADC $E7         ; ...
         STA $E7         ; ...
         SEP #$20        ; ...
         LDY $EB         ; Actor slot
         INY             ; Actor slot +1
         CPY #$0010      ; Done all 16?
         BNE C3EEB1      ; Loop if not

; Fork: Default to "??????" (Gogo, Umaro)
C3EED9:  LDX $00         ; Dst index: 0
         LDA #$CB        ; Char: "?"			=== SNES: Different tile number
C3EEDD:  STA $7E9E89,X   ; Add to string
         INX             ; Index +1
         CPX #$0006      ; Done 6 chars?
         BNE C3EEDD      ; Loop if not
         BRA C3EEF9      ; Skip alt case

; Fork: Load actor's name
C3EEE9:  LDX $00         ; Dst index: 0
C3EEEB:  LDA $0002,Y     ; Letter
         STA $7E9E89,X   ; Add to string
         INY             ; Src index +1
         INX             ; Dst index +1
         CPX #$0006      ; Done 6 chars?
         BNE C3EEEB      ; Loop if not
C3EEF9:  JSR C3EF03      ; Center name
         JSR C3AF6E      ; Build tilemap
         JSR C3AF98      ; Load graphics
         RTS

; Center BG3 camera on actor's pseudonym		%%% SNES: Each character's width differs
C3EF03:  LDX $00         ; Letter: 1st
         TXY             ; Space count: 0
C3EF06:  LDA $7E9E89,X   ; Letter
         STA $7E9E93,X   ; No use...
         CMP #$FF        ; Space char?
         BNE C3EF13      ; Skip if not
         INY             ; Space count +1
C3EF13:  INX             ; Char index +1
         CPX #$0006      ; Done all 6?
         BNE C3EF06      ; Loop if not
         REP #$20        ; 16-bit A
         TYA             ; Space count
         ASL A           ; x2
         ASL A           ; x4 pixels
         EOR #$FFFF      ; Invert value
         INC A           ; Add one
         STA $3D         ; Set BG3 X-Pos
         SEP #$20        ; 8-bit A
         RTS













; Set to temporarily scroll BG1 westward
C3EF27:  STY $F3         ; Save timer
         LDA #$00        ; Min slot: 0
         LDY #C3EF3C     ; C3/EF3C
         JSR C311DE      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA $F3         ; Scroll timer
         STA $7E3349,X   ; Set mode timer
         SEP #$20        ; 8-bit A
         RTS

; Temporarily scroll BG1 westward
C3EF3C:  LDX $2D         ; Queue index
         REP #$20        ; 16-bit A
         LDA $3349,X     ; Timer expired?
         BEQ C3EF58      ; Dequeue if so
         DEC $3349,X     ; Timer -1
         SEP #$20        ; 8-bit A
         LDA $23         ; NMI count
         AND #$03        ; Now 0-3
         BNE C3EF56      ; Pause if > 0
         REP #$20        ; 16-bit A
         INC $35         ; BG1 X-Pos +1
         SEP #$20        ; 8-bit A
C3EF56:  SEC             ; Set to requeue
         RTS             ; Exit
C3EF58:  SEP #$20        ; 8-bit A
         CLC             ; Set to dequeue
         RTS

; Create actor's first and last names
C3EF5C:  TDC             ; Clear A
         LDA $28         ; Actor
         ASL A           ; x2
         ASL A           ; x4
         STA $E0         ; Memorize it
         LDA $28         ; Actor
         ASL A           ; Double it
         CLC             ; Prepare ADC
         ADC $E0         ; Now x6
         TAX             ; Index it
         REP #$20        ; 16-bit A
         LDA $C28DD4,X   ; Anim ptr A			=== SNES address differs
         STA $4D         ; Memorize it
         SEP #$20        ; 8-bit A
         LDA $C28DD6,X   ; Name A's X			=== SNES address differs
         STA $53         ; Memorize it
         REP #$20        ; 16-bit A
         LDA $C28DD7,X   ; Anim ptr B			=== SNES address differs
         STA $4F         ; Memorize it
         SEP #$20        ; 8-bit A
         LDA $C28DD9,X   ; Name B's X			=== SNES address differs
         STA $54         ; Memorize it
         JSR C3EFC9      ; Queue A's anim
         REP #$20        ; 16-bit A
         LDA $4D         ; Anim table ptr
         STA $7E32C9,X   ; Set name A's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA $53         ; X position
         STA $7E33CA,X   ; Set name A's
         LDA #$D0        ; Y: 208
         STA $7E344A,X   ; Set name A's
         JSR C3EFC9      ; Queue B's anim
         REP #$20        ; 16-bit A
         LDA $4F         ; Anim table ptr
         STA $7E32C9,X   ; Set name B's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA $54         ; X position
         STA $7E33CA,X   ; Set name B's
         LDA #$D0        ; Y: 208
         STA $7E344A,X   ; Set name B's
         RTS

; Queue true actor name or "And you"
C3EFC9:  LDA #$01        ; Min slot: 8
         LDY #C3EE2D     ; C3/EE2D
         JSR C311DE      ; Queue anim fn
         RTS

; Create "And you"
C3EFD2:  JSR C3EFC9      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$F85B      ; Anim table ptr		=== SNES: CF/F8AB
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$68        ; X: 104
         STA $7E33CA,X   ; Set sprite's
         LDA #$D0        ; Y: 208
         STA $7E344A,X   ; Set sprite's
         RTS

; Initialize font, BG, and register data for actor scene
C3EFF3:  STA $28         ; Set actor slot
         JSL $D4CE8C     ; Init registers
         JSR C371D0      ; Clear BG3 A
         JSR C371BC      ; Clear BG2 A
         LDA #$C3        ; Src HB
         LDY #$3049      ; To BG pal 0
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; BGP0: Black
         LDA #$C3        ; Src HB
         LDY #$3069      ; To BG pal 1
         LDX #C3115F     ; C3/115F
         JSR C30FF9      ; BGP1: Black
         LDA #$C3        ; Src HB
         LDY #$3089      ; To BG pal 2
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; BGP2: Black
         LDA #$C3        ; Src HB
         LDY #$30E9      ; To BG pal 5
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; BGP5: Black
         LDA #$C3        ; Src HB
         LDY #$3109      ; To BG pal 6
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; BGP6: Black
         LDA #$C3        ; Src HB
         LDY #$3149      ; To OBJ pal 0
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; OBP0: Black
         LDA #$C3        ; Src HB
         LDY #$3169      ; To OBJ pal 1
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; OBP1: Black
         LDA #$C3        ; Src HB
         LDY #$31C9      ; To OBJ pal 4
         LDX #C3115F     ; Src LBs
         JSR C30FF9      ; OBP4: Black
         JSR C3FDAE      ; Load big font
         JMP C3FDCA      ; And BG GFX/map

; Create and upload text for actor scene, unblank screen
C3F05D:  STZ $47         ; Erase name: N
         JSR C3F7D1      ; Create "as"
         LDA #$2C        ; Palette 3
         STA $29         ; No use...
         JSR C3EEAF      ; Create alias
         LDA #$01        ; CGRAM: Freeze
         TRB $45         ; Set NMI flag
         JSR C31517      ; Upload alias
         LDA #$01        ; CGRAM: Refresh
         TSB $45         ; Set NMI flag
         JSR C3EF5C      ; Create true name
C3F077:  JSR C3FE5B      ; Queue BG1+BG3a
         INC $26         ; Scene mode +1
         JMP C3D5E7      ; Set brightness

; Set to fade BG elements for actor scene (also final airship's)
C3F07F:  LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$30E9      ; To BG pal 5
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Do tabletop
         LDA #$C3        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$3109      ; To BG pal 6
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Do overlay
C3F0A5:  LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$3069      ; To BG pal 1
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Do book, etc.
         LDA #$C3        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$3089      ; To BG pal 2
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Do bones, etc.
         RTS

; Set to fade in BG elements for actor scene
C3F0CC:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$02        ; Slowness: 2
         LDY #$3069      ; To BG pal 1
         STY $E7         ; ...
         LDX #$9674      ; C2/9674			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do book, etc.
         LDA #$C2        ; ...
         STA $ED         ; ...
         LDA #$02        ; Slowness: 2
         LDY #$3089      ; To BG pal 2
         STY $E7         ; ...
         LDX #$9694      ; C2/9694			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do bones, etc.
         LDA #$C2        ; ...
         STA $ED         ; ...
         LDA #$02        ; Slowness: 2
         LDY #$30E9      ; To BG pal 5
         STY $E7         ; ...
         LDX #$96D4      ; C2/96D4			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do tabletop
         LDA #$C2        ; ...
         STA $ED         ; ...
         LDA #$02        ; Slowness: 2
         LDY #$3109      ; To BG pal 6
         STY $E7         ; ...
         LDX #$96F4      ; C2/96F4			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Do overlay
         RTS

; Set to fade in actor's pseudonym and "as"
C3F119:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$3049      ; To BG pal 0
         STY $E7         ; ...
         LDX #$974C      ; C2/974C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Handle name
         LDA #$C2        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$3169      ; To OBJ pal 1
         STY $E7         ; ...
         LDX #$974C      ; C2/974C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Handle "as"
         RTS

; Set to scroll and fade actor alias, fade "as", fade in true name
C3F140:  STZ $CF         ; Scroll timer LB
         STZ $D0         ; Scroll timer HB
         LDY #$00F0      ; Frames: 240
         STY $64         ; Set scroll limit
         LDA #$00        ; Min slot: 0
         LDY #C3E13A     ; C3/E13A
         JSR C311DE      ; Queue scroll fn
         JSR C3F17B      ; Fade pseudonym
         LDA #$C3        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$3169      ; To OBJ pal 1
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Fade "as"
C3F167:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$3149      ; To OBJ pal 0
         STY $E7         ; ...
         LDX #$974C      ; C2/974C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Fade in true name
         RTS

; Set to fade background palette 0
C3F17B:  LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$3049      ; To BG pal 0
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Queue fade-out
         RTS

; Set to fade sprite palette 0
C3F18F:  LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$3149      ; To OBJ pal 0
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Queue fade-out
         RTS

; Set to return to event script
C3F1A3:  LDA #$FF        ; Null value
         STA $26         ; Next: Exit
         RTS

; 28: Start Shadow's scene
C3F1A8:  LDA #$03        ; Actor: Shadow
         JSR C3EFF3      ; Init BGs/font
         JSR C3FE82      ; Upload apple
         JSR C3F0CC      ; Fade in BGs
         JSR C3F1C4      ; Fade in apple
         JSR C3F779      ; Scroll table
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for alias
         JSR C3F8ED      ; Create apple
         JMP C3F05D      ; Create text

; Set to fade in non-glint sprites on table
C3F1C4:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$02        ; Slowness: 2
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #$976C      ; C2/976C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Queue fade-in
         RTS

; Set to fade sprite palette 4
C3F1D8:  LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$04        ; Slowness: 4
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Queue fade-out
         RTS

; 29: Fade in "Shadow as"
C3F1EC:  LDY $20         ; Delay expired?
         BNE C3F1FA      ; Exit if not
         INC $26         ; Next: C3/F1FB
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F1FA:  RTS

; 2A: Switch Shadow's names
C3F1FB:  LDY $20         ; Delay expired?
         BNE C3F209      ; Exit if not
         INC $26         ; Next: C3/F20A
         JSR C3F140      ; Switch names
         LDY #$0168      ; Fade/Pan delay
         STY $20         ; Set for below
C3F209:  RTS

; 2B: Fade all but Shadow's name
C3F20A:  LDY $20         ; Delay expired?
         BNE C3F220      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade apple
         JSR C3F77F      ; Scroll table
C3F220:  RTS

; 38: Fade actor's true name
C3F221:  LDY $20         ; Delay expired?
         BNE C3F231      ; Exit if not
         LDY #$0078      ; Frames: 120
         STY $20         ; Set exit delay
         LDA #$01        ; C3/D543
         STA $26         ; Next: Exit
         JSR C3F18F      ; Queue fade-out
C3F231:  RTS

; 32: Start Cyan's scene
C3F232:  LDA #$02        ; Actor: Cyan
         JSR C3EFF3      ; Init BGs/font
         JSR C3FEA2      ; Draw sword; GFX
         JSR C3F0CC      ; Fade in BGs
         JSR C3F3A2      ; Fade in glint
         LDY #$FFB8      ; X: -72 = 440
         STY $35         ; Set BG1 X-Pos
         JSR C3F773      ; Scroll table
         JSR C3FB70      ; Queue glints
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for alias
         JMP C3F05D      ; Create text

; 33: Fade in "Cyan as"
C3F253:  LDY $20         ; Delay expired?
         BNE C3F261      ; Exit if not
         INC $26         ; Next: C3/F262
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F261:  RTS

; 34: Switch Cyan's names
C3F262:  LDY $20         ; Delay expired?
         BNE C3F270      ; Exit if not
         INC $26         ; Next: C3/F271
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F270:  RTS

; 35: Fade all but Cyan's name
C3F271:  LDY $20         ; Delay expired?
         BNE C3F284      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade glint
C3F284:  RTS

; 40: Start Edgar and Sabin's scene
C3F285:  LDA #$04        ; Actor: Edgar
         JSR C3EFF3      ; Init BGs/font
         JSR C3FEB8      ; Upload coin
         JSR C3F0CC      ; Fade in BGs
         JSR C3F1C4      ; Fade in coin
         JSR C3FB5E      ; Queue coin fn
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 41: Fade in "Edgar as"
C3F29E:  LDY $20         ; Delay expired?
         BNE C3F2AC      ; Exit if not
         INC $26         ; Next: C3/F2AD
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for alias
C3F2AC:  RTS

; 42: Switch Edgar's names
C3F2AD:  LDY $20         ; Delay expired?
         BNE C3F2BB      ; Exit if not
         INC $26         ; Next: C3/F2BC
         JSR C3F140      ; Switch names
         LDY #$00F0      ; Intro delay
         STY $20         ; Set for Sabin
C3F2BB:  RTS

; 43: Show Sabin's name, fade Edgar's
C3F2BC:  LDY $20         ; Delay expired?
         BNE C3F2DB      ; Exit if not
         LDY $00         ; ...
         STY $3F         ; BG3 Y-Pos: 0
         LDA #$05        ; Actor: Sabin
         STA $28         ; Set actor slot
         JSR C3F7D1      ; Create "as"
         JSR C3F18F      ; Fade Edgar
         JSR C3EEAF      ; Create Sabin
         JSR C3F119      ; Fade in Sabin
         INC $26         ; Next: C3/F2DC
         LDY #$0078      ; Removal delay
         STY $20         ; Set for Edgar
C3F2DB:  RTS

; 44: Delete Edgar's name
C3F2DC:  LDY $20         ; Delay expired?
         BNE C3F2EB      ; Exit if not
         LDA #$01        ; Erase name: Y
         STA $47         ; Set sprite flag
         INC $26         ; Next: C3/F2EC
         LDY #$00B4      ; Switch delay
         STY $20         ; Set for Sabin
C3F2EB:  RTS

; 45: Switch Sabin's names
C3F2EC:  LDY $20         ; Delay expired?
         BNE C3F306      ; Exit if not
         LDA #$4F        ; C3/F307
         STA $26         ; Next: Fade BG
         LDY #$00B4      ; Frames: 180
         STY $20         ; Set fade delay
         STZ $47         ; Erase name: N
         LDY #$0014      ; Frames: 20
         STY $85         ; Set scroll delay
         JSR C3EF5C      ; Create true name
         JSR C3F140      ; Switch names
C3F306:  RTS

; 4F: Fade all but Sabin's name
C3F307:  LDY $20         ; Delay expired?
         BNE C3F31A      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade coin
C3F31A:  RTS

; 3C: Start Mog's scene
C3F31B:  LDA #$0A        ; Actor: Mog
         JSR C3EFF3      ; Init BGs/font
         JSR C3FEDC      ; Draw tree; GFX
         JSR C3F0CC      ; Fade in BGs
         JSR C3F1C4      ; Fade in sprites
         JSR C3F779      ; Scroll table
         JSR C3F95E      ; Create sprites
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 3D: Fade in "Mog as"
C3F337:  LDY $20         ; Delay expired?
         BNE C3F345      ; Exit if not
         INC $26         ; Next: C3/F346
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F345:  RTS

; 3E: Switch Mog's names
C3F346:  LDY $20         ; Delay expired?
         BNE C3F354      ; Exit if not
         INC $26         ; Next: C3/F355
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F354:  RTS

; 3F: Fade all but Mog's name
C3F355:  LDY $20         ; Delay expired?
         BNE C3F36B      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade sprites
         JSR C3F77F      ; Scroll table
C3F36B:  RTS

; 46: Start Gogo's scene
C3F36C:  LDA #$0C        ; Actor: Gogo
         JSR C3EFF3      ; Init BGs/font
         JSR C3FEF2      ; Draw helmet; eye
         JSR C3F0CC      ; Fade in BGs
         JSR C3F773      ; Scroll table
         JSR C3F91E      ; Create pink eye
         LDA #$02        ; Min slot: 16
         LDY #C3F3D9     ; C3/F3D9
         JSR C311DE      ; Queue eye fn
         LDA #$B4        ; Eye delay
         LDA $7E3349,X   ; Bug: LDA -> STA
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 47: Fade in "Gogo as"
C3F393:  LDY $20         ; Delay expired?
         BNE C3F3A1      ; Exit if not
         INC $26         ; Next: C3/F3B6
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for nameS
C3F3A1:  RTS

; Set to fade in glint on table object
C3F3A2:  LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$01        ; Slowness: 1
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #$9554      ; C2/9554			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Queue fade-in
         RTS

; 48: Switch Gogo's names
C3F3B6:  LDY $20         ; Delay expired?
         BNE C3F3C4      ; Exit if not
         INC $26         ; Next: C3/F3C5
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F3C4:  RTS

; 49: Fade all but Gogo's name
C3F3C5:  LDY $20         ; Delay expired?
         BNE C3F3D8      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade eye
C3F3D8:  RTS

; Animate eye in Gogo's helmet
C3F3D9:  TAX             ; Index mode
         JMP (C3F3DD,X)  ; Handle mode

; Jump table for Gogo's eye
C3F3DD:  dw C3F3E5       ; Wait
         dw C3F3F4       ; Fade in eye
         dw C3F3E5       ; Wait
         dw C3F419       ; Fade out eye

; Modes 0 and 2: Wait
C3F3E5:  LDX $2D         ; Queue index
         LDA $3349,X     ; Timer expired?
         BNE C3F3EF      ; Branch if not
         INC $3649,X     ; Mode +1
C3F3EF:  DEC $3349,X     ; Timer -1
         SEC             ; Set to requeue
         RTS

; Mode 1: Fade in eye
C3F3F4:  PHB             ; Save DB
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$01        ; Slowness: 1
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #$9574      ; C2/9574			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Queue fade-in
         PLB             ; Restore DB
         LDX $2D         ; Queue index
         LDA #$3C        ; Delay: 60
         STA $3349,X     ; Set fade-out's
         INC $3649,X     ; Mode +1
         SEC             ; Set to requeue
         RTS

; Mode 3: Fade out eye
C3F419:  PHB             ; Save DB
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         LDA #$C3        ; C3/115F
         STA $ED         ; Set src HB
         LDA #$01        ; Slowness: 1
         LDY #$31C9      ; To OBJ pal 4
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Queue fade
         PLB             ; Restore DB
         CLC             ; Set to dequeue
         RTS

; 50: Start Gau's scene
C3F434:  LDA #$0B        ; Actor: Gau
         JSR C3EFF3      ; Init BGs/font
         JSR C3FF08      ; Draw helmet; face
         JSR C3F0CC      ; Fade in BGs
         JSR C3F1C4      ; Fade in face
         JSR C3F779      ; Scroll table
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 51: Fade in "Gau as"
C3F44D:  LDY $20         ; Delay expired?
         BNE C3F45B      ; Exit if not
         INC $26         ; Next: C3/F45C
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F45B:  RTS

; 52: Switch Gau's names; create face
C3F45C:  LDY $20         ; Delay expired?
         BNE C3F46D      ; Exit if not
         INC $26         ; Next: C3/F46E
         JSR C3F8CE      ; Create face
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F46D:  RTS

; 53: Fade all but Gau's name
C3F46E:  LDY $20         ; Delay expired?
         BNE C3F484      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade face
         JSR C3F77F      ; Scroll table
C3F484:  RTS

; 5A: Start Terra's scene
C3F485:  LDA #$00        ; Actor: Terra
         JSR C3EFF3      ; Init BGs/font
         JSR C3FF1E      ; Draw glass; GFX
         JSR C3F0CC      ; Fade in BGs
         JSR C3F3A2      ; Fade in glint
         JSR C3F779      ; Scroll table
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 5B: Fade in "Terra as"
C3F49E:  LDY $20         ; Delay expired?
         BNE C3F4AC      ; Exit if not
         INC $26         ; Next: C3/F4AD
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F4AC:  RTS

; 5C: Switch Terra's names, create glint
C3F4AD:  LDY $20         ; Delay expired?
         BNE C3F4BE      ; Exit if not
         INC $26         ; Next: C3/F4BF
         JSR C3F93D      ; Create glint
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F4BE:  RTS

; 5D: Fade all but Terra's name
C3F4BF:  LDY $20         ; Delay expired?
         BNE C3F4D5      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade glint
         JSR C3F77F      ; Scroll table
C3F4D5:  RTS

; 64: Start Locke and Celes's scene
C3F4D6:  LDA #$01        ; Actor: Locke
         JSR C3EFF3      ; Init BGs/font
         JSR C3FF34      ; Draw bouquet
         JSR C3F0CC      ; Fade in BGs
         JSR C3F779      ; Scroll table
         LDY #$FFE0      ; X: -32 = 480
         STY $35         ; Set BG1 X-Pos
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 65: Fade in "Locke as"
C3F4F1:  LDY $20         ; Delay expired?
         BNE C3F4FF      ; Exit if not
         INC $26         ; Next: C3/F500
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for alias
C3F4FF:  RTS

; 66: Switch Locke's names
C3F500:  LDY $20         ; Delay expired?
         BNE C3F50E      ; Exit if not
         INC $26         ; Next: C3/F50F
         JSR C3F140      ; Switch names
         LDY #$00F0      ; Intro delay
         STY $20         ; Set for Celes
C3F50E:  RTS

; 67: Show Celes's name, fade Locke's
C3F50F:  LDY $20         ; Delay expired?
         BNE C3F52E      ; Exit if not
         LDY $00         ; ...
         STY $3F         ; BG3 Y-Pos: 0
         LDA #$06        ; Actor: Celes
         STA $28         ; Set actor slot
         JSR C3F7D1      ; Create "as"
         JSR C3F18F      ; Fade Locke
         JSR C3EEAF      ; Create Celes
         JSR C3F119      ; Fade in Celes
         INC $26         ; Next: C3/F52F
         LDY #$0078      ; Removal delay
         STY $20         ; Set for Locke
C3F52E:  RTS

; 68: Delete Locke's name
C3F52F:  LDY $20         ; Delay expired?
         BNE C3F53E      ; Exit if not
         LDA #$01        ; Erase name: Y
         STA $47         ; Set sprite flag
         INC $26         ; Next: C3/F53F
         LDY #$00B4      ; Switch delay
         STY $20         ; Set for Celes
C3F53E:  RTS

; 69: Switch Celes's names
C3F53F:  LDY $20         ; Delay expired?
         BNE C3F557      ; Exit if not
         INC $26         ; Next: C3/F558
         LDY #$00B4      ; Frames: 180
         STY $20         ; Set fade delay
         STZ $47         ; Erase name: N
         LDY #$0014      ; Frames: 20
         STY $85         ; Set scroll delay
         JSR C3EF5C      ; Create true name
         JSR C3F140      ; Switch names
C3F557:  RTS

; 6A: Fade all but Celes's name
C3F558:  LDY $20         ; Delay expired?
         BNE C3F56E      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; No sprites...
         JSR C3F77F      ; Scroll table
C3F56E:  RTS

; 6E: Start Relm's scene
C3F56F:  LDA #$08        ; Actor: Relm
         JSR C3EFF3      ; Init BGs/font
         JSR C3FF47      ; Draw brush; GFX
         JSR C3F0CC      ; Fade in BGs
         JSR C3F3A2      ; Fade in glint
         JSR C3F779      ; Scroll table
         JSR C3FB67      ; Queue glints
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 6F: Fade in "Relm as"
C3F58B:  LDY $20         ; Delay expired?
         BNE C3F599      ; Exit if not
         INC $26         ; Next: C3/F59A
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F599:  RTS

; 70: Switch Relm's names
C3F59A:  LDY $20         ; Delay expired?
         BNE C3F5A8      ; Exit if not
         INC $26         ; Next: C3/F5A9
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F5A8:  RTS

; 71: Fade all but Relm's name
C3F5A9:  LDY $20         ; Delay expired?
         BNE C3F5BF      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade glint
         JSR C3F77F      ; Scroll table
C3F5BF:  RTS

; 78: Start Strago's scene
C3F5C0:  LDA #$07        ; Actor: Strago
         JSR C3EFF3      ; Init BGs/font
         JSR C3FF5D      ; Draw book
         JSR C3F0CC      ; Fade in BGs
         JSR C3FCB9      ; Queue book fn
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for name
         JMP C3F05D      ; Create text

; 79: Fade in "Strago as"
C3F5D6:  LDY $20         ; Delay expired?
         BNE C3F5E4      ; Exit if not
         INC $26         ; Next: C3/F5E5
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F5E4:  RTS

; 7A: Switch Strago's names
C3F5E5:  LDY $20         ; Delay expired?
         BNE C3F5F3      ; Exit if not
         INC $26         ; Next: C3/F5F4
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F5F3:  RTS

; 7B: Fade all but Strago's name
C3F5F4:  LDY $20         ; Delay expired?
         BNE C3F607      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; No sprites...
C3F607:  RTS

; 2D: Start first book scene
C3F608:  JSR C3EFF3      ; Init BGs/font
         JSR C3FF5D      ; Draw book
         JSR C3F0CC      ; Fade in BGs
         LDY #$02D0      ; Frames: 720
         STY $20         ; Set anim delay
         JMP C3F077      ; Queue BG1, etc.

; 2E: Animate first book
C3F619:  LDY $20         ; Delay expired?
         BNE C3F627      ; Exit if not
         INC $26         ; Next: C3/F628
         JSR C3FCCE      ; Queue book fn
         LDY #$01E0      ; Frames: 480
         STY $20         ; Set wait timer
C3F627:  RTS

; 2F: Wait 480 frames
C3F628:  LDY $20         ; Delay expired?
         BNE C3F633      ; Exit if not
         INC $26         ; Next: C3/F634
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F633:  RTS

; 30: Pixelate and fade first book
C3F634:  LDY $20         ; Delay expired?
         BNE C3F64A      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Exit
         JSR C3F785      ; Queue mosaic
         LDY #$0078      ; Frames: 120x2
         STY $20         ; Set exit delay
         JSR C3F07F      ; Fade BGs
         JSR C3F77F      ; Scroll table
C3F64A:  RTS

; 4A: Start last book scene
C3F64B:  JSR C3EFF3      ; Init BGs/font
         JSR C3FF5D      ; Draw book
         JSR C3F0CC      ; Fade in BGs
         JSR C3FCE3      ; Queue book fn
         LDY #$00B4      ; Frames: 180
         STY $20         ; Set wait timer
         STZ $47         ; Erase text: N
         JSR C3EFD2      ; Create "And you"
         JMP C3F077      ; Queue BG1, etc.

; 4B: Wait 180 frames
C3F664:  LDY $20         ; Delay expired?
         BNE C3F66F      ; Exit if not
         INC $26         ; Next: C3/F670
         LDY #$00EC      ; Freeze delay
         STY $20         ; Set for book
C3F66F:  RTS

; 4C: Stop last book and fade in text
C3F670:  LDY $20         ; Delay expired?
         BNE C3F682      ; Exit if not
         LDA #$01        ; Last page: Y
         STA $99         ; Set book flag
         INC $26         ; Next: C3/F683
         LDY #$016C      ; Frames: 364
         STY $20         ; Set fade delay
         JSR C3F167      ; Queue fade-in
C3F682:  RTS

; 4D: Pixelate and fade last book
C3F683:  LDY $20         ; Delay expired?
         BNE C3F696      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd text
         JSR C3F785      ; Queue mosaic
         LDY #$0078      ; Fade delay
         STY $20         ; Set for text
         JSR C3F07F      ; Fade BGs
C3F696:  RTS

; 82: Start Setzer's scene
C3F697:  LDA #$09        ; Actor: Setzer
         JSR C3EFF3      ; Init BGs/font
         JSR C3FF70      ; Upload cards
         JSR C3F0CC      ; Fade in BGs
         LDA #$C3        ; Pal loc HB
         LDY #$3189      ; To OBJ pal 2
         LDX #C3115F     ; Pal loc LBs
         JSR C30FF9      ; Cards: Black
         LDA #$C2        ; Bank: C2
         STA $ED         ; Set src HB
         LDA #$02        ; Slowness: 2
         LDY #$3189      ; To OBJ pal 2
         STY $E7         ; ...
         LDX #$976C      ; C2/976C			=== SNES address differs
         STX $EB         ; ...
         JSR C31015      ; Fade in cards
         JSR C3F773      ; Scroll table
         JSR C3F81D      ; Create cards
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for alias
         JMP C3F05D      ; Create text

; 83: Fade in "Setzer as"
C3F6CE:  LDY $20         ; Delay expired?
         BNE C3F6DC      ; Exit if not
         INC $26         ; Next: C3/F6DD
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F6DC:  RTS

; 84: Switch Setzer's names
C3F6DD:  LDY $20         ; Delay expired?
         BNE C3F6EB      ; Exit if not
         INC $26         ; Next: C3/F6EC
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F6EB:  RTS

; 85: Fade background
C3F6EC:  LDY $20         ; Delay expired?
         BNE C3F6FA      ; Exit if not
         INC $26         ; Next: C3/F6FB
         LDY #$0078      ; Fade delay
         STY $20         ; Set for cards
         JSR C3F07F      ; Fade BGs
C3F6FA:  RTS

; 86: Fade cards and name
C3F6FB:  LDY $20         ; Delay expired?
         BNE C3F71E      ; Exit if not
         LDY #$0078      ; Frames: 120
         STY $20         ; Set exit delay
         LDA #$01        ; C3/D543
         STA $26         ; Next: Exit
         JSR C3F18F      ; Fade name
         LDA #$C3        ; ...
         STA $ED         ; ...
         LDA #$04        ; Slowness: 4
         LDY #$3189      ; To OBJ pal 2
         STY $E7         ; ...
         LDX #C3115F     ; Black palette
         STX $EB         ; ...
         JSR C31015      ; Fade cards
C3F71E:  RTS

; 87: Start Umaro's scene
C3F71F:  LDA #$0D        ; Actor: Umaro
         JSR C3EFF3      ; Init BGs/font
         JSR C3FFAC      ; Draw bones; GFX
         JSR C3F0CC      ; Fade in BGs
         JSR C3F1C4      ; Fade in sprites
         JSR C3F779      ; Scroll table
         JSR C3F7FE      ; Create skull
         JSR C3F9B6      ; Create moogles
         LDY #$0078      ; Fade-in delay
         STY $20         ; Set for alias
         JMP C3F05D      ; Create text

; 88: Fade in "Umaro as"
C3F73E:  LDY $20         ; Delay expired?
         BNE C3F74C      ; Exit if not
         INC $26         ; Next: C3/F74D
         JSR C3F119      ; Queue fade-in
         LDY #$00F0      ; Switch delay
         STY $20         ; Set for names
C3F74C:  RTS

; 89: Switch Umaro's names
C3F74D:  LDY $20         ; Delay expired?
         BNE C3F75B      ; Exit if not
         INC $26         ; Next: C3/F75C
         JSR C3F140      ; Switch names
         LDY #$0168      ; Frames: 360
         STY $20         ; Set fade delay
C3F75B:  RTS

; 8A: Fade all but Umaro's name
C3F75C:  LDY $20         ; Delay expired?
         BNE C3F772      ; Exit if not
         LDA #$38        ; C3/F221
         STA $26         ; Next: Fd name
         LDY #$0078      ; Fade delay
         STY $20         ; Set for name
         JSR C3F07F      ; Fade BGs
         JSR C3F1D8      ; Fade sprites
         JSR C3F77F      ; Scroll table
C3F772:  RTS

; Set to scroll BG1 westward for 20 seconds
C3F773:  LDY #$04B0      ; Frames: 1200
         JMP C3EF27      ; Queue panning

; Set to scroll BG1 westward for 5.2 seconds
C3F779:  LDY #$0138      ; Frames: 312
         JMP C3EF27      ; Queue panning

; Set to scroll BG1 westward for 3 seconds
C3F77F:  LDY #$00B4      ; Frames: 180
         JMP C3EF27      ; Queue panning

; Queue mosaic effect for book
C3F785:  TDC             ; Min slot: 0
         LDY #C3F78C     ; C3/F78C
         JMP C311DE      ; Queue anim fn

; Handle mosaic effect for book
C3F78C:  TAX             ; Index mode
         JMP (C3F790,X)  ; Handle mode

; Jump table for the above
C3F790:  dw C3F794       ; Initialize mosaic
         dw C3F79F       ; Sustain mosaic

; Mode 0: Initialize mosaic
C3F794:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         STZ $33CA,X     ; Intensity: 0
         STZ $3349,X     ; Wait timer: 0

; Mode 1: Sustain mosaic
C3F79F:  LDX $2D         ; Queue index
         LDA $3349,X     ; Delay expired?
         BEQ C3F7AB      ; Proceed if so
         DEC $3349,X     ; Delay -1
         SEC             ; Set to requeue
         RTS             ; Exit
C3F7AB:  LDA $33CA,X     ; Intensity
         ORA #$0F        ; Layers: All
         STA $B5         ; Set mosaic
         LDX $2D         ; ...
         LDA $33CA,X     ; Intensity
         CLC             ; Prepare ADC
         ADC #$10        ; Intensity +1
         STA $33CA,X     ; Save changes
         LDA #$10        ; Frames: 16
         STA $3349,X     ; Set next wait
         SEC             ; Set to requeue
         RTS

; Scroll BG1 westward (unused)
C3F7C4:  LDA $23         ; NMI count
         AND #$03        ; Now 0-3
         BNE C3F7D0      ; Exit if > 0
         REP #$20        ; 16-bit A
         INC $35         ; BG1 X-Pos +1
         SEP #$20        ; 8-bit A
C3F7D0:  RTS

; Create "as"
C3F7D1:  LDA #$03        ; Min slot: 24
         LDY #C3EDD4     ; C3/EDD4
         JSR C311DE      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$8E28      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         LDA #$0258      ; Frames: 600
         STA $7E3349,X   ; Set hide delay
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$79        ; X: 121
         STA $7E33CA,X   ; Set sprite's
         LDA #$C0        ; Y: 192
         STA $7E344A,X   ; Set sprite's
         RTS

; Create Umaro's skull
C3F7FE:  JSR C3F90C      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$F51E      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$C4        ; X: 196
         STA $7E33CA,X   ; Set sprite's
         LDA #$4F        ; Y: 79
         JMP C3F9A2      ; Set Y, pan flag

; Create four playing cards
C3F81D:  JSR C3F8B4      ; Queue card 1
         LDA #$78        ; X: 120
         STA $7E33CA,X   ; Set card 1's
         LDA #$50        ; X: 80
         STA $7E33CA,X   ; Should be Y...
         REP #$20        ; 16-bit A
         LDA #$0080      ; V-Spd: +0.5 px
         STA $7E3549,X   ; Set card 1's
         LDA #$0020      ; H-Spd: +0.125 px
         STA $7E34C9,X   ; Set card 1's
         SEP #$20        ; 8-bit A
         JSR C3F8B4      ; Queue card 2
         LDA #$04        ; Pose timer: 4
         STA $7E36CA,X   ; Overwritten...
         LDA #$48        ; X: 72
         STA $7E33CA,X   ; Set card 2's
         LDA #$C0        ; Y: 192
         STA $7E344A,X   ; Set card 2's
         REP #$20        ; 16-bit A
         LDA #$0060      ; V-Spd: +0.375 px
         STA $7E3549,X   ; Set card 2's
         LDA #$0040      ; H-Spd: +0.25 px
         STA $7E34C9,X   ; Set card 2's
         SEP #$20        ; 8-bit A
         JSR C3F8B4      ; Queue card 3
         LDA #$0C        ; Pose timer: 12
         STA $7E36CA,X   ; Overwritten...
         LDA #$98        ; X: 152
         STA $7E33CA,X   ; Set card 3's
         LDA #$10        ; Y: 16
         STA $7E344A,X   ; Set card 3's
         REP #$20        ; 16-bit A
         LDA #$0080      ; V-Spd: +0.5 px
         STA $7E3549,X   ; Set card 3's
         LDA #$FFE0      ; H-Spd: -0.125 px
         STA $7E34C9,X   ; Set card 3's
         SEP #$20        ; 8-bit A
         JSR C3F8B4      ; Queue card 4
         LDA #$12        ; Pose timer: 18
         STA $7E36CA,X   ; Overwritten...
         LDA #$D0        ; X: 208
         STA $7E33CA,X   ; Set card 4's
         LDA #$80        ; Y: 128
         STA $7E344A,X   ; Set card 4's
         REP #$20        ; 16-bit A
         LDA #$0080      ; V-Spd: +0.5 px
         STA $7E3549,X   ; Set card 4's
         LDA #$00A0      ; H-Spd: +0.625 px
         STA $7E34C9,X   ; Set card 4's
         SEP #$20        ; 8-bit A
         RTS

; Queue current playing card
C3F8B4:  LDA #$00        ; Min slot: 0
         LDY #C3EDFB     ; C3/EDFB
         JSR C311DE      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$92F2      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         RTS

; Create face in Gau's diving helmet
C3F8CE:  JSR C3F90C      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$F5F7      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$CB        ; X: 203
         STA $7E33CA,X   ; Set sprite's
         LDA #$5F        ; Y: 95
         JMP C3F9A2      ; Set Y, pan flag

; Create Shadow's apple
C3F8ED:  JSR C3F90C      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$948F      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         LDA #$C0        ; X: 192
         STA $7E33CA,X   ; Set sprite's
         LDA #$57        ; Y: 87
         JMP C3F9A2      ; Set Y, pan flag

; Queue regular permanent sprite
C3F90C:  LDA #$03        ; Min slot: 24
         LDY #C3EDFB     ; C3/EDFB
         JSR C311DE      ; Queue OAM fn
         RTS

; Queue regular permanent sprite (unused variant)
C3F915:  LDA #$02        ; Min slot: 16
         LDY #C3EDFB     ; C3/EDFB
         JSR C311DE      ; Queue OAM fn
         RTS

; Create glowing eye in Gogo's helmet
C3F91E:  JSR C3F90C      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$F400      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$C8        ; X: 200
         STA $7E33CA,X   ; Set sprite's
         LDA #$61        ; Y: 97
         JMP C3F9A2      ; Set Y, pan flag

; Create glint on Terra's pendant
C3F93D:  JSR C3F90C      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$F564      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$80        ; X: 128
         STA $7E33CA,X   ; Set sprite's
         LDA #$60        ; Y: 96
         STA $7E344A,X   ; Set sprite's
         RTS

; Create Mog's mini moogles and winding key
C3F95E:  JSR C3F90C      ; Queue key anim
         REP #$20        ; 16-bit A
         LDA #$F4C5      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set key's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA #$E0        ; X: 224
         STA $7E33CA,X   ; Set key's
         LDA #$6F        ; Y: 111
         JSR C3F9A2      ; Set Y, pan flag
         JSR C3F9AD      ; Queue moogle 1
         LDA #$BA        ; X: 186
         STA $7E33CA,X   ; Set moogle 1's
         JSR C3F9AD      ; Queue moogle 2
         LDA #$C6        ; X: 198
         STA $7E33CA,X   ; Set moogle 2's
         JSR C3F9AD      ; Queue moogle 3
         LDA #$D1        ; X: 209
         STA $7E33CA,X   ; Set moogle 3's
         JSR C3F9AD      ; Queue moogle 4
         LDA #$DC        ; X: 220
         STA $7E33CA,X   ; Set moogle 4's
         RTS

; Set sprite to pan with BG1, define Y position
C3F9A2:  STA $7E344A,X   ; Set Y position
C3F9A6:  LDA #$01        ; Pans with BG1
         STA $7E364A,X   ; Set sprite flags
         RTS

; Queue current mini moogle
C3F9AD:  LDA #$02        ; Min slot: 16
         LDY #C3FA36     ; C3/FA36
         JSR C311DE      ; Queue anim fn
         RTS

; Create Umaro's moogles
C3F9B6:  JSR C3F9AD      ; Queue moogle 1
         JSR C3FA2F      ; Anim mode: 5
         LDA #$3A        ; Base X: 58
         STA $7E33CA,X   ; Set moogle 1's
         REP #$20        ; 16-bit A
         LDA #$01A4      ; Frames: 420
         STA $7E3349,X   ; Set walk timer
         LDA #$F42F      ; Bump anim ptr		=== SNES address differs
         STA $7E37C9,X   ; Set moogle 1's
         SEP #$20        ; 8-bit A
         JSR C3F9AD      ; Queue moogle 2
         JSR C3FA2F      ; Anim mode: 5
         LDA #$2E        ; Base X: 46
         STA $7E33CA,X   ; Set moogle2's
         REP #$20        ; 16-bit A
         LDA #$01B8      ; Frames: 440
         STA $7E3349,X   ; Set walk timer
         LDA #$F435      ; Bump anim ptr		=== SNES address differs
         STA $7E37C9,X   ; Set moogle2's
         SEP #$20        ; 8-bit A
         JSR C3F9AD      ; Queue moogle 3
         JSR C3FA2F      ; Anim mode: 5
         LDA #$21        ; Base X: 33
         STA $7E33CA,X   ; Set moogle 3's
         REP #$20        ; 16-bit A
         LDA #$01CC      ; Frames: 460
         STA $7E3349,X   ; Set walk timer
         LDA #$F43B      ; Bump anim ptr		=== SNES address differs
         STA $7E37C9,X   ; Set moogle 3's
         SEP #$20        ; 8-bit A
         JSR C3F9AD      ; Queue moogle 4
         JSR C3FA2F      ; Anim mode: 5
         LDA #$14        ; Base X: 20
         STA $7E33CA,X   ; Set moogle 3's
         REP #$20        ; 16-bit A
         LDA #$01E0      ; Frames: 480
         STA $7E3349,X   ; Set walk timer
         LDA #$F441      ; Bump anim ptr		=== SNES address differs
         STA $7E37C9,X   ; Set moogle 4's
         SEP #$20        ; 8-bit A
         RTS

; Initialize moogle's animation mode for Umaro
C3FA2F:  LDA #$05        ; Approach bones
         STA $7E3649,X   ; Set anim mode
         RTS

; Animate mini moogle
C3FA36:  TAX             ; Index mode
         JMP (C3FA3A,X)  ; Handle mode

; Jump table
C3FA3A:  dw C3FA4A       ; Initialize data
         dw C3FA6F       ; Spin around
         dw C3FA98       ; Face left
         dw C3FAB5       ; Jump down
         dw C3FAD1       ; Walk away from tree
         dw C3FAD6       ; Initialize data
         dw C3FAE3       ; Walk toward bones
         dw C3FB0A       ; Stop and fall down

; Mode 0: Initialize data
C3FA4A:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$F408      ; Anim table ptr		=== SNES address differs
         STA $32C9,X     ; Set sprite's
         LDA #$0168      ; Frames: 360
         STA $3349,X     ; Set spin timer
         SEP #$20        ; 8-bit A
         LDA #$64        ; Y: 100
         STA $344A,X     ; Set sprite's
         LDA #$CF        ; Bank: CF
         STA $35CA,X     ; Set ptr HB
         JSR C3F9A6      ; Follow BG1: Y
         JSR C31271      ; Set pose timer

; Mode 1: Spin around
C3FA6F:  LDX $2D         ; Queue index
         LDY $3349,X     ; Mode expired?
         BNE C3FA90      ; Branch if not
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$F42C      ; Anim table ptr		=== SNES address differs
         STA $32C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $35CA,X     ; Set ptr HB
         LDA #$10        ; Frames: 16
         STA $3349,X     ; Set jump timer
         JSR C31271      ; Set pose timer
C3FA90:  JSR C3DF69      ; Mode timer -1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Mode 2: Jump down
C3FA98:  LDX $2D         ; Queue index
         LDY $3349,X     ; Mode expired?
         BNE C3FAA7      ; Branch if not
         INC $3649,X     ; Mode +1
         LDA #$3C        ; Frames: 60
         STA $3349,X     ; Set walk delay
C3FAA7:  JSR C3DF69      ; Mode timer -1
         JSR C3FB2A      ; Adjust Y-Pos
         JSR C3EE10      ; Scroll & OAM
         INC $35C9,X     ; Y-Pos mod +1
         SEC             ; Set to requeue
         RTS

; Mode 3: Face left
C3FAB5:  LDX $2D         ; Queue index
         LDY $3349,X     ; Mode expired?
         BNE C3FAC9      ; Branch if not
         JSR C3FB0F      ; Set to walk
         REP #$20        ; 16-bit A
         LDA #$012C      ; Frames: 300
         STA $3349,X     ; No use...
         SEP #$20        ; 8-bit A
C3FAC9:  JSR C3DF69      ; Mode timer -1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Mode 4: Walk away from tree
C3FAD1:  JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Mode 5: Initialize data
C3FAD6:  LDX $2D         ; Queue index
         JSR C3FB0F      ; Set to walk
         LDA #$70        ; Y: 112
         STA $344A,X     ; Set sprite's
         JSR C3F9A6      ; Follow BG1: Y

; Mode 6: Walk toward bones
C3FAE3:  LDX $2D         ; Queue index
         LDY $3349,X     ; Mode expired?
         BNE C3FB02      ; Branch if not
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         STZ $34C9,X     ; H-Speed: 0
         LDA $37C9,X     ; Queue anim ptr
         STA $32C9,X     ; Set as current
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
C3FB02:  JSR C3DF69      ; Mode timer -1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Mode 7: Stop and fall down
C3FB0A:  JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Set mini moogle to walk eastward
C3FB0F:  INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$F423      ; Anim table ptr		=== SNES address differs
         STA $32C9,X     ; Set sprite's
         LDA #$0040      ; H-Spd: +0.25 px
         STA $34C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $35CA,X     ; Set ptr HB
         JMP C31271      ; Set pose timer

; Adjust jumping mini moogle's Y position
C3FB2A:  LDX $2D         ; Queue index
         LDA $35C9,X     ; Modifier index
         AND #$0F        ; ...
         TAX             ; Index it
         LDA $CFF50E,X   ; Y modifier			=== SNES: $CFF55E
         STA $E0         ; Memorize it
         BMI C3FB47      ; Branch if up
         LDX $2D         ; Queue index
         LDA $344A,X     ; Sprite's Y
         CLC             ; Prepare ADC
         ADC $E0         ; Add modifier
         STA $344A,X     ; Save changes
         BRA C3FB5D      ; Exit

; Fork: Shift upward
C3FB47:  LDX $2D         ; Queue index
         LDA $00E0       ; Y modifier
         BPL C3FB51      ; ...
         EOR #$FF        ; Invert it
         INC A           ; Add 1
C3FB51:  STA $00E0       ; Save changes
         LDA $344A,X     ; Sprite's Y
         SEC             ; Prepare SBC
         SBC $E0         ; Sub modifier
         STA $344A,X     ; Save changes
C3FB5D:  RTS

; Queue double-headed coin
C3FB5E:  LDA #$02        ; Min slot: 16
         LDY #C3FC73     ; C3/FC73
         JSR C311DE      ; Queue anim fn
         RTS

; Set to create glints on brush
C3FB67:  LDA #$00        ; Min slot: 0
         LDY #C3FB82     ; C3/FB82
         JSR C311DE      ; Queue anim fn
         RTS

; Set to create glints on katana
C3FB70:  LDA #$00        ; Min slot: 0
         LDY #C3FBE8     ; C3/FBE8
         JSR C311DE      ; Queue anim fn
         RTS

; Queue brush or katana glint
C3FB79:  LDA #$02        ; Min slot: 16
         LDY #C3FC4E     ; C3/FC4E
         JSR C311DE      ; Queue anim fn
         RTS

; Create a series of glints on Relm's brush
C3FB82:  TAX             ; Index mode
         JMP (C3FB86,X)  ; Handle mode

; Jump table for the above
C3FB86:  dw C3FB8A       ; Initialize wave
         dw C3FBA1       ; Create wave

; Mode 0: Initialize wave
C3FB8A:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$0168      ; Frames: 360
         STA $3349,X     ; Set wave delay
         SEP #$20        ; 8-bit A
         LDA #$E4        ; X: 228
         STA $C7         ; Set base X
         LDA #$03        ; Glints: 3
         STA $C9         ; Set counter

; Mode 1: Create wave
C3FBA1:  LDA $C9         ; Glints left
         BEQ C3FBE6      ; Dequeue if 0
         LDX $2D         ; Queue index
         LDY $3349,X     ; Delay expired?
         BNE C3FBE1      ; Branch if not
         LDA #$08        ; Frames: 8
         STA $3349,X     ; Set next delay
         PHB             ; Save DB
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         JSR C3FB79      ; Queue glint
         LDA #$68        ; Y: 104
         STA $7E344A,X   ; Set glint's
         REP #$20        ; 16-bit A
         LDA #$F564      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set glint's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA $C7         ; Base X
         STA $7E33CA,X   ; Set glint's
         PLB             ; Restore DB
         DEC $C7         ; Base X -1
         DEC $C7         ; Base X -1
         DEC $C7         ; Base X -1
         DEC $C7         ; Base X -1
         DEC $C9         ; Glints left -1
C3FBE1:  JSR C3DF69      ; Delay -1
         SEC             ; Set to requeue
         RTS             ; Exit
C3FBE6:  CLC             ; Set to dequeue
         RTS

; Create a series of glints on Cyan's katana
C3FBE8:  TAX             ; Index mode
         JMP (C3FBEC,X)  ; Handle mode

; Jump table for the above
C3FBEC:  dw C3FBF0       ; Initialize wave
         dw C3FC07       ; Create wave

; Mode 0: Initialize wave
C3FBF0:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$0168      ; Frames: 360
         STA $3349,X     ; Set wave delay
         SEP #$20        ; 8-bit A
         LDA #$C8        ; X: 200
         STA $C7         ; Set base X
         LDA #$04        ; Glints: 4
         STA $C9         ; Set counter

; Mode 1: Create wave
C3FC07:  LDA $C9         ; Glints left
         BEQ C3FC4C      ; Dequeue if 0
         LDX $2D         ; Queue index
         LDY $3349,X     ; Delay expired?
         BNE C3FC47      ; Branch if not
         LDA #$08        ; Frames: 8
         STA $3349,X     ; Set next delay
         PHB             ; Save DB
         LDA #$00        ; ...
         PHA             ; ...
         PLB             ; ...
         JSR C3FB79      ; Queue glint
         LDA #$60        ; Y: 96
         STA $7E344A,X   ; Set glint's
         REP #$20        ; 16-bit A
         LDA #$F5AA      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set glint's
         SEP #$20        ; 8-bit A
         LDA #$CF        ; Bank: CF
         STA $7E35CA,X   ; Set ptr HB
         LDA $C7         ; Base X
         STA $7E33CA,X   ; Set glint's
         PLB             ; Restore DB
         DEC $C7         ; Base X -1
         DEC $C7         ; Base X -1
         DEC $C7         ; Base X -1
         DEC $C7         ; Base X -1
         DEC $C9         ; Glints left -1
C3FC47:  JSR C3DF69      ; Delay -1
         SEC             ; Set to requeue
         RTS             ; Exit
C3FC4C:  CLC             ; Set to dequeue
         RTS

; Animate glint on brush or katana
C3FC4E:  TAX             ; Index mode
         JMP (C3FC52,X)  ; Handle mode

; Jump table for the above
C3FC52:  dw C3FC56       ; Initialize sprite
         dw C3FC63       ; Sustain sprite

; Mode 0: Initialize sprite
C3FC56:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         LDA #$01        ; Pans with BG1
         STA $364A,X     ; Set OBJ flags
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3FC63:  LDX $2D         ; Queue index
         LDA $36CA,X     ; Pose timer
         CMP #$FE        ; Set as endless?
         BEQ C3FC71      ; Delete if so
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS             ; Exit
C3FC71:  CLC             ; Set to dequeue
         RTS

; Animate double-headed coin
C3FC73:  TAX             ; Index mode
         JMP (C3FC77,X)  ; Handle mode

; Jump table for the above
C3FC77:  dw C3FC7B       ; Initialize sprite
         dw C3FCA7       ; Sustain sprite

; Mode 0: Initialize sprite
C3FC7B:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$ED1D      ; Anim table ptr		=== SNES address differs
         STA $32C9,X     ; Set sprite's
         LDA #$0080      ; H-Spd: +0.5 px
         STA $34C9,X     ; Set sprite's
         SEP #$20        ; 8-bit A
         LDA #$C8        ; Frames: 200
         STA $3349,X     ; Set roll timer
         LDA #$D8        ; Bank: D8
         STA $35CA,X     ; Set ptr HB
         LDA #$10        ; X: 16
         STA $33CA,X     ; Set sprite's
         LDA #$64        ; Y: 100
         STA $344A,X     ; Set sprite's
         JSR C31271      ; Set pose timer

; Mode 1: Sustain sprite
C3FCA7:  LDX $2D         ; Queue index
         LDA $3349,X     ; Stop rolling?
         BNE C3FCB1      ; Branch if not
         STZ $34C9,X     ; H-Speed: 0
C3FCB1:  DEC $3349,X     ; Roll timer -1
         JSR C3EE10      ; Scroll & OAM
         SEC             ; Set to requeue
         RTS

; Set to animate Strago's book
C3FCB9:  JSR C3FCF8      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$8B62      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set book's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         RTS

; Set to animate first book
C3FCCE:  JSR C3FCF8      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$8B53      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set book's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         RTS

; Set to animate last book
C3FCE3:  JSR C3FCF8      ; Queue anim fn
         REP #$20        ; 16-bit A
         LDA #$8B35      ; Anim table ptr		=== SNES address differs
         STA $7E32C9,X   ; Set book's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $7E35CA,X   ; Set ptr HB
         RTS

; Set to animate book
C3FCF8:  TDC             ; Clear A
         TAY             ; Clear Y
         STA $99         ; Last page: N
         STY $60         ; Always 0...
         LDA #$01        ; Min slot: 8
         LDY #C3FD3E     ; C3/FD3E
         JSR C311DE      ; Queue anim fn
         RTS

; Integrate decompressed tilemap segment, adjust attributes
C3FD07:  STX $E7         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $E9         ; Set src HB
         STY $EB         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
         LDX $00         ; Rows done: 0
         REP #$20        ; 16-bit A
C3FD17:  TDC             ; Clear A
         TAY             ; Index: 0
C3FD19:  LDA [$E7],Y     ; Attributes
         CLC             ; Prepare ADC
         ADC $60         ; Always 0...
         STA [$EB],Y     ; Put in map
         INY             ; Index +1
         INY             ; Index +1
         CPY $E0         ; End of row?
         BNE C3FD19      ; Loop if not
         LDA $E7         ; Source LBs
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         STA $E7         ; Save changes
         LDA $EB         ; Dest LBs
         CLC             ; Prepare ADC
         ADC #$0040      ; Go 1 row down
         STA $EB         ; Save changes
         INX             ; Rows done +1
         CPX $E2         ; More left?
         BNE C3FD17      ; Loop if so
         SEP #$20        ; 8-bit A
         RTS

; Animate book
C3FD3E:  TAX             ; Index mode
         JMP (C3FD42,X)  ; Handle mode

; Jump table for the above
C3FD42:  dw C3FD48       ; Initialize timer
         dw C3FD52       ; Check if last page
         dw C3FD56       ; Update tilemap

; Mode 0: Initialize timer
C3FD48:  LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         JSR C31271      ; Set pose timer
         SEC             ; Set to requeue
         RTS

; Mode 1: Check if last page
C3FD52:  LDA $99         ; Last page?
         BNE C3FD93      ; Branch if so

; Mode 2: Update tilemap
C3FD56:  LDX $2D         ; Queue index
         JSR C31292      ; Pose timer -1
         LDX $2D         ; Queue index
         SEP #$10        ; 8-bit X, Y
         LDA $36C9,X     ; Pose index
         TAY             ; Index it
         REP #$20        ; 16-bit A
         LDA [$EB],Y     ; Pose info loc
         STA $E7         ; Set src LBs
         INY             ; ...
         INY             ; ...
         SEP #$20        ; 8-bit A
         LDA $35CA,X     ; Anim ptr HB
         STA $E9         ; Set src HB
         REP #$10        ; 16-bit X, Y
         LDY $00         ; Src index: 0
         REP #$20        ; 16-bit A
         LDA [$E7],Y     ; Column count
         STA $E0         ; Set width
         INY             ; Src index +1
         INY             ; Src index +1
         LDA [$E7],Y     ; Row count
         STA $E2         ; Set height
         INY             ; Src index +1
         INY             ; Src index +1
         LDA [$E7],Y     ; Source LBs
         TAX             ; Put in X
         INY             ; Src index +1
         INY             ; Src index +1
         LDA [$E7],Y     ; Dest LBs
         TAY             ; Put in Y
         SEP #$20        ; 8-bit A
         JSR C3FD07      ; Replace tiles
         SEC             ; Set to requeue
         RTS

; Fork: Set to stop animation
C3FD93:  STZ $99         ; ...
         LDX $2D         ; Queue index
         INC $3649,X     ; Mode +1
         REP #$20        ; 16-bit A
         LDA #$8B44      ; Anim table ptr		=== SNES address differs
         STA $32C9,X     ; Set book's
         SEP #$20        ; 8-bit A
         LDA #$C2        ; Bank: C2
         STA $35CA,X     ; Set ptr HB
         JSR C31271      ; Set pose timer
         BRA C3FD56      ; Replace tiles

; Unpack and upload large font graphics for actor scene
C3FDAE:  LDY #$B500      ; Source LBs			=== SNES: BA00
         LDA #$CE        ; Source HB			=== SNES: C4
         JSR C3ECB1      ; Unpack GFX
         LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0900      ; Bytes: 2304
         STY $EB         ; Set data size
         LDY #$7000      ; VRAM pointer
         JMP C3ECD6      ; Upload GFX

; Unpack and upload BG graphics and tilemaps for actor scene
C3FDCA:  LDY #$BB08      ; Source LBs			=== SNES: C008
         LDA #$CE        ; Source HB			=== SNES: C3
         JSR C3ECB1      ; Unpack data

; Fork: Copy table's map to BG1 tilemap A
C3FDD2:  LDY #$3849      ; BG1 map A
         STY $EB         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
         JSR C3FE4A      ; Move data

; Fork: Copy table's map to BG1 tilemap B
C3FDDE:  LDY #$4049      ; BG1 map B
         STY $EB         ; Set dst LBs
         LDA #$7E        ; Bank: 7E
         STA $ED         ; Set dst HB
         JSR C3FE4A      ; Move data

; Fork: Upload tall items and table side graphics
C3FDEA:  LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$1F60      ; Bytes: 8032
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$3000      ; VRAM pointer
         JSR C3ED09      ; Upload data

; Fork: Upload large items, tabletop, and overlay graphics
C3FE02:  LDY #$DF60      ; 7E/DF60
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0B40      ; Bytes: 2880
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$4000      ; VRAM pointer
         JSR C3ED09      ; Upload data

; Fork: Upload book graphics
C3FE1A:  LDY #$EAA0      ; 7E/EAA0
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0E00      ; Bytes: 3584
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$5000      ; VRAM pointer
         JSR C3ED09      ; Upload data

; Fork: Upload transparent overlay tilemap (BG2)
C3FE32:  LDY #$0448      ; 7F/0448
         STY $E7         ; Set src LBs
         LDA #$7F        ; Bank: 7F
         STA $E9         ; Set src HB
         LDY #$0780      ; Bytes: 1920
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$1000      ; VRAM pointer
         JMP C3ED09      ; Upload data

; Relocate decompressed tilemap for table
C3FE4A:  LDY #$F8A0      ; 7E/F8A0
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0780      ; Bytes: 1920
         STY $EF         ; Set data size
         JMP C3E653      ; Move data

; Set to upload BG1 and BG3 tilemaps for actor scene
C3FE5B:  LDY #$1800      ; $1800
         STY $1B         ; Set VRAM ptr
         LDY #$7849      ; 7E/7849
         STY $1D         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $1F         ; Set src HB
         LDY #$0800      ; Bytes: 2048
         STY $19         ; Set data size
         LDY #$0000      ; $0000
         STY $14         ; Set VRAM ptr
         LDY #$3849      ; 7E/3849
         STY $16         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $18         ; Set src HB
         LDY #$1000      ; Bytes: 4096
         STY $12         ; Set data size
         RTS

; Unpack and upload apple and shuriken graphics
C3FE82:  LDY #$EF77      ; Source LBs			=== SNES: F477
         LDA #$CE        ; Source HB			=== SNES: C4
         JSR C3ECB1      ; Unpack GFX
         LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0380      ; Bytes: 896
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$6000      ; VRAM pointer
         JMP C3ED09      ; Upload GFX

; Draw Cyan's katana; unpack and upload glint
C3FEA2:  JSR C3FF70      ; Handle glint
         LDY #$0026      ; Tiles: 19
         STY $E0         ; Set width
         LDY #$0002      ; Tiles: 2
         STY $E2         ; Set height
         LDX #$03E0      ; Src: 7F/03E0
         LDY #$3BA1      ; Dst: 7E/3BA1
         JMP C3FD07      ; Draw katana

; Unpack and upload coin graphics
C3FEB8:  JSR C3FEC1      ; Unpack data
         LDY #$6000      ; VRAM pointer
         JMP C3ED09      ; Upload data

; Unpack skull and coin graphics; prepare upload
C3FEC1:  LDY #$9D4B      ; Source LBs			=== SNES: 9D4B
         LDA #$D9        ; Source HB
         JSR C3ECB1      ; Unpack GFX
         LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0800      ; Bytes: 896
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         RTS

; Draw Mog's tree; unpack and upload sprites
C3FEDC:  JSR C3FF70      ; Do sprites
         LDY #$000E      ; Tiles: 7
         STY $E0         ; Set width
         LDY #$0008      ; Tiles: 8
         STY $E2         ; Set height
         LDX #$0020      ; Src: 7F/0020
C3FEEC:  LDY #$3A77      ; Dst: 7E/3A77
         JMP C3FD07      ; Draw tree

; Draw Gogo's helmet; unpack and upload glint
C3FEF2:  JSR C3FF70      ; Handle glint
         LDY #$001C      ; Tiles: 14
         STY $E0         ; Set width
         LDY #$0009      ; Tiles: 9
         STY $E2         ; Set height
         LDX #$002E      ; Src: 7F/002E
         LDY #$3A2D      ; Dst: 7E/3A2D
         JMP C3FD07      ; Draw helmet

; Draw Gau's diving helmet; unpack and upload face
C3FF08:  JSR C3FF90      ; Handle face
         LDY #$000C      ; Tiles: 6
         STY $E0         ; Set width
         LDY #$0007      ; Tiles: 7
         STY $E2         ; Set height
         LDX #$004A      ; Src: 7F/004A
         LDY #$3AB7      ; Dst: 7E/3AB7
         JMP C3FD07      ; Draw helmet

; Draw Terra's cocktail glasses; unpack and upload glint
C3FF1E:  JSR C3FF70      ; Handle glint
         LDY #$000E      ; Tiles: 7
         STY $E0         ; Set width
         LDY #$0005      ; Tiles: 5
         STY $E2         ; Set height
         LDX #$0220      ; Src: 7F/0220
         LDY #$3B35      ; Dst: 7E/3B35
         JMP C3FD07      ; Draw glasses

; Draw Locke and Celes's bouquet
C3FF34:  LDY #$0018      ; Tiles: 12
         STY $E0         ; Set width
         LDY #$0006      ; Tiles: 6
         STY $E2         ; Set height
         LDX #$0274      ; Src: 7F/0274
         LDY #$3B69      ; Dst: 7E/3B69
         JMP C3FD07      ; Replace tiles

; Draw Relm's brush; unpack and upload glint
C3FF47:  JSR C3FF70      ; Handle glint
         LDY #$0014      ; Tiles: 10
         STY $E0         ; Set width
         LDY #$0002      ; Tiles: 2
         STY $E2         ; Set height
         LDX #$0360      ; Src: 7F/0360
         LDY #$3BF3      ; Dst: 7E/3BF3
         JMP C3FD07      ; Draw brush

; Draw an open book
C3FF5D:  LDY #$001C      ; Tiles: 14
         STY $E0         ; Set width
         LDY #$0006      ; Tiles: 6
         STY $E2         ; Set height
         LDX #$0BC8      ; Src: 7F/0BC8
         LDY #$3AD9      ; Dst: 7E/3AD9
         JMP C3FD07      ; Replace tiles

; Unpack and upload card, glint, moogle, and winding key graphics
C3FF70:  LDY #$F1FB      ; Source LBs			=== SNES: F6FB
         LDA #$CE        ; Source HB			=== SNES: C4
         JSR C3ECB1      ; Unpack GFX
         LDY #$C000      ; 7E/C000
         STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$0DF0      ; Bytes: 3568
         STY $EB         ; Set data size
         STZ $ED         ; Attrib LB: 0
         STZ $EE         ; Attrib HB: 0
         LDY #$6000      ; VRAM pointer
         JMP C3ED09      ; Upload GFX

; Unpack and upload face graphics for Gau's scene
C3FF90:  LDY #$A4E5      ; Source LBs
         LDA #$D9        ; Source HB
         JSR C3ECB1      ; Unpack GFX
         LDY #$C000      ; 7E/C000
C3FF9B:  STY $E7         ; Set src LBs
         LDA #$7E        ; Bank: 7E
         STA $E9         ; Set src HB
         LDY #$00C0      ; Bytes: 192
         STY $EB         ; Set data size
         LDY #$6000      ; VRAM pointer
         JMP C3ECD6      ; Upload GFX

; Draw Umaro's bones; unpack and upload sprites
C3FFAC:  JSR C3FF70      ; Handle moogles
         JSR C3FEC1      ; Unpack skull
         LDY #$6800      ; VRAM pointer
         JSR C3ED09      ; Upload skull
         LDY #$000A      ; Tiles: 5
         STY $E0         ; Set width
         LDY #$0005      ; Tiles: 5
         STY $E2         ; Set height
         LDX #$0056      ; Src: 7F/0056
         LDY #$3B37      ; Dst: 7E/3B37
         JMP C3FD07      ; Draw bones

; Old version of C3/FF90 (partially deleted)		%%%
C3FFCB:  db $E9          ; [STA] $E9
         LDY #$00C0      ; Bytes: 192
         STY $EB         ; Set data size
         LDY #$6000      ; VRAM pointer
         JMP $ED01       ; Upload GFX

; Old version of C3/FFAC				%%%
C3FFD7:  JSR C3FF9B      ; Handle moogles
         JSR C3FEEC      ; Unpack skull
         LDY #$6800      ; VRAM pointer
         JSR $ED34       ; Upload skull
         LDY #$000A      ; Tiles: 5
         STY $E0         ; Set width
         LDY #$0005      ; Tiles: 5
         STY $E2         ; Set height
         LDX #$0056      ; Src: 7F/0056
         LDY #$3B37      ; Dst: 7E/3B37
         JMP $FD32       ; Draw bones
